This post originated from an RSS feed registered with PHP Buzz
by Stephan Schmidt.
Original Post: 1c Services_Ebay 0.8.0 released 13
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
e6e
I just released a new version of my PEAR package Services_Ebay, which is now marked as alpha as the API starts to stabilize.
This version includes some quite interesting new features: Services_Ebay now provides some kind of introspection, as you can get a list of all supported API calls using Services_Ebay::getAvailableCalls(). Furthermore it finally supports a changeable SiteId, that means it's not restricted to ebay.com anymore.
To help you debugging your application and to help me analysing the bug reports it's now also possible to capture the XML data that is sent to and recieved from the eBay webservice.
But the coolest new feature are the custom models, an idea I had in the Toby's and Lukas' powerworkshop. They used Services_Ebay in conjunction with some other PEAR packages, but wanted to store some additional information for the items in a database. To achieve this, they created a new object that stored a reference to a Services_Ebay_Model_Item object and the additional data that they wanted to store in the database. Although this worked, it did not look very nice and can get quite messy.
To achieve the same result, you may now create new model items to replace the ones provided by Services_Ebay. That means you can create classes for users, items, feedback etc. that will automatically created and filled with data by the Services_Ebay package. All you have to do is the following: <?php;
require_once 'Services/Ebay.php';
// simple model class
// You may implement any additional methods you need
// in your custom models.
class myItem extends Services_Ebay_Model_Item
{
// Dummy method
// This does not really do anything, but you can implement whatever you like
// here...
public function StoreItem()
{
echo "Now you could store the item data in your local database...";
}
}
Services_Ebay::useModelClass('Item', 'myItem');
$session = Services_Ebay::getSession($devId, $appId, $certId);
$session->setToken($token);
$ebay = new Services_Ebay($session);
$item = $ebay->GetItem('4501296414');
$item->StoreItem();
?>
This is totally simple and allows you to add any functionality you need in your application without wrapping methods or duplicating code.
17