The Artima Developer Community
Sponsored Link

PHP Buzz Forum
Making huge progress with Services_Ebay

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.
Making huge progress with Services_Ebay Posted: Sep 14, 2004 4:22 AM
Reply to this message Reply

This post originated from an RSS feed registered with PHP Buzz by Stephan Schmidt.
Original Post: Making huge progress with Services_Ebay
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
1a72 About 6 months ago, I started a wrapper for the eBay webservice and created a draft in Pepr.
As I realized that eBay already is promoting a PHP package for accessing their API, I put this project on hold and worked on my other projects. But after some coverage of the project by Harry Fuecks and the PHP Magazine Adam Trachtenberg, technical evangelist at eBay, contacted me and asked me to update the project to implement eBay's new authentication method.
After we exchanged some mails, Adam told me that there's no official eBay package for PHP yet and so I started working on this again.
This was about 10 days ago, and I made huge progress already. I implemented 50 of the available API calls and now only some of the seldomly used methods are left to implement. The project makes heavy use of PHP5's new OO-features like overloading (methods are loaded on demand) and SPL's iterators. This allows you to work with eBay entities, like they were some native PHP objects, available on your system. Adam, who already saw some of my examples, was absolutely amazed, how easy it is to work with the complex API.
But enough of the talk and let's take a look at some examples:

<?PHP
// get information about a user
$user = $ebay->GetUser('superman-74');
// display user ID
echo $user->UserId;

// display all user data
print_r($user->toArray());

// get feedback for the user
$feedback = $user->getFeedback(Services_Ebay::FEEDBACK_BRIEF);
foreach ($feedback as $entry) {
echo $entry;
}
?>


All these return values are objects, that may also be used in foreach() loops or echo'd to the user, overloading will take care of how they are handled.

Adding a new item is also easy as baking cake:

<?PHP
$item = Services_Ebay::loadModel('Item');
$item->Category = 57882;
$item->Title = 'Supergirl\'s cape';
$item->Description = 'Another test item';
$item->Location = 'At my home';
$item->MinimumBid = '1000.0';
$item->VisaMaster = 1;

// Add the item
$result = $ebay->AddItem($item);
?>


If you realised that there's a mistake in the recently added item, just change it and send it back to eBay:

<?PHP
$item = $ebay->GetItem('ItemId');
$item->Title = 'The new title';
$ebay->ReviseItem($item);
?>


Most methods can be either called on the Services_Ebay object or on the model directly:

<?PHP
$item = $ebay->GetItem('ItemId');
$item->Title = 'The new title';
$item->Revise();
?>


When calling a method, you may either pass scalar parameters in the parameter order defined in the call object itself or you pass an associative array, using the names specified in the official API documentation. This keeps Services_Ebay simple for all users, while offering the full, complex functionality for the users who want to use advanced features of the API.

Services_Ebay already provides Calls and Models for working with users, items, searchresults, feedback, transactions, feedback, MyEbay, etc.

All code and a lot of examples are available in my CVS, there you can see all methods that have been implemented at a glance.

I'll probably start a real PEAR proposal next week, so this can be included in PEAR as fast as possible. 26a

Read: Making huge progress with Services_Ebay

Topic: Response to 'How Will Companies Ever Make Money Off Open Source?' Previous Topic   Next Topic Topic: d Marcus Blogs! 11

Sponsored Links



Google
  Web Artima.com   

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