This post originated from an RSS feed registered with PHP Buzz
by Stephan Schmidt.
Original Post: 25 First public release of Services_Ebay 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
12d4
Today, I released the first public version of the PHP5-package Services_Ebay, which provides a very easy way to access the eBay XML API with PHP5.
Although the package is still in devel state, it supports about 50 of the 70 API calls that the eBay web service offers. Furthermore it adds model classes for eBay users, items, feedback, categories, etc. that helps you working with the eBay data. By making use of PHP5's new OO-features, you may access properties of eBay items as if they were native PHP data structures. The easiest way to demonstrate this, is a tiny example. The following code snippet fetches an eBay item: <?php
require_once 'Services/Ebay.php';
$session = Services_Ebay::getSession($devId, $appId, $certId);
$session->setToken($token);
$ebay = new Services_Ebay($session);
$item = $ebay->GetItem(4501333179);
echo 'User-Id of the seller: '.$item->Seller->UserId;
print_r($item->toArray());
?>
If you are the seller of the item, you may revise the item and send it back to eBay using the following code: <?php
$item->Title = 'The new item title';
$item->ReviseItem();
?>
Working with other entities, like users or categories, is also extremely easy: <?php
$supes = $ebay->GetUser('superman-74');
$feedback = $supes->getFeedback( Services_Ebay::FEEDBACK_VERBOSE, 1, 10 );
foreach ($feedback as $entry) {
echo 'Feedback for '.$feedback->ItemNumber."\n";
echo $feedback;
echo "\n";
}
?>
All models provide are using methods like __call(), __get() and __toString() so they can be used in several ways.
The Services_Ebay class is loading the API calls on demand and thus reduces the code that needs to be parsed. Each API call may be used in three ways:
Use it with the Services_Ebay class and pass arguments like you would pass them to a standard PHP function (you need to pass only the most important parameters).
Use it with the Servcies_Ebay class and pass arguments as an associative array (needed, when sending complex queries)
Instantiate the object on its own, pass arguments to the constructor.
Furthermore, the API calls are able to describe their parameter list by calling $call->describeCall();
To use the package, you will need to register as an eBay developer at http://developer.ebay.com and then create an authentication token from the token generation tool at the developer site.