The Artima Developer Community
Sponsored Link

PHP Buzz Forum
Services_Ebay 0.11.0 released

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Stephan Schmidt

Posts: 238
Nickname: schst
Registered: Sep, 2004

Stephan Schmidt is a founding member of PHP Application Tools and a PEAR developer.
Services_Ebay 0.11.0 released Posted: Feb 3, 2005 10:27 AM
Reply to this message Reply

This post originated from an RSS feed registered with PHP Buzz by Stephan Schmidt.
Original Post: Services_Ebay 0.11.0 released
Feed Title: a programmer's best friend
Feed URL: http://blog.php-tools.net/rss.php?version=1.0
Feed Description: The blog of PHP Application Tools
Latest PHP Buzz Posts
Latest PHP Buzz Posts by Stephan Schmidt
Latest Posts From a programmer's best friend

Advertisement
I just released a new version of Services_Ebay, which provides two cool new features, as well as several new API-calls. On of the new features is the new caching system, I added to the model classes. As API calls to the eBay API tend to be quite time consuming (and expensive) most users probably will be trying to cache the return values from the eBay API. So I decided to add this as an optional feature to Services_Ebay. Using the cache is extremely easy:
<?php
$session = Services_Ebay::getSession($devId, $appId, $certId);
$session->setToken($token);

// build a filesystem cache
$userCache = Services_Ebay::loadCache('Filesystem', array('path' => './cache'));

// use a static expiry of 15 minutes
$userCache->setExpiry('Static', 15);

// use this cache for all user models
Services_Ebay_Model_User::setCache($userCache);

// load a new user model
$user = Services_Ebay::loadModel('User', 'superman-74', $session);

if ($user->isCached()) {
echo 'data had been cached';
print_r($user->toArray());
} else {
echo 'fetching user data from eBay';
$user->Get();

print_r($user->toArray());
}
?>

After instantiating a new cache container, you set the type of expiry you want to use for caching the data. Currently only a fixed expiry time is supported, but this can be changed easily (as expiry checks are objects) and thus an expiry check will be added that caches data of eBay items shorter the nearer the end of the auction draws. I'll probably also add cache containers based on databases, as the are more flexible than filesystem caches.

The second feature I added (with some help by the fabulous Adam Trachtenberg) is the support for product finders. Product finders are those neat and advanced forms that eBay provides on their website, which lets you choose the style, color, size of clothing or any other item you are looking for. eBay's API provides to calls that help you adding those interactive search tools to your site as well: GetProductFinder, which returns XML code with the raw information (form elements and values for a certain category) and GetProductFinderXSL which returns the stylesheet eBay uses to render the HTML from the raw XML data. Services_Ebay makes working with these calls extremely easy, as it provides a ProductFinder model:
<?php
$session = Services_Ebay::getSession($devId, $appId, $certId);
$session->setToken($token);
$ebay = new Services_Ebay($session);

// load the product finder XSL, fetching it everytime as too expensive
$xsl = file_get_contents('product_finder.xsl');

// get product finder
list($productFinder) = $ebay->GetProductFinder(1909);
echo $productFinder->render($xsl);
}
?>

Using this code will result in 4 drop-down menus as well as some javascript, which will update them, whenever the user selects an item.

The new release is also the first release which features code by Carsten Lucke, who added two new API calls (that deal with Dutch auctions and member messages) as well as the needed models for these calls.

Read: Services_Ebay 0.11.0 released

Topic: PHPSC Slashdotted Previous Topic   Next Topic Topic: Leading PHP Experts Join Forces to Establish the PHP Security Consortium

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use