[photo] Mark Jeftovic

easyDNS CEO, Career Contrarian & AntiGuru

Ebay’s move to free and grokking PHP’s Services_Ebay

Ebay made a very smart move recently and removed most of the costs associated with their developer platform. I think this will bring a lot of innovative new services to the market as the barrier to entry is now largely technical and not financial.

One of the reasons Amazon’s AWS and affiliate program is so ubiquitous across the net is largely due to two things: 1) the depth and stickiness of the Amazon site and 2) the free access to their affiliate and AWS services.

Ebay has one of the few sites whose depth and prevalence approaches that of Amazon, although a back-of-the-napkin comparison shows Amazon dwarfs Ebay in backlinks by about 28 million to 6 million.

I started playing with PHP’s pear class Services_Ebay and after some struggling, I finally have a handle on it and thought I’d post some of the “aha” links which helped get me there.

Programming eBay Web Services with PHP 5 and Services_Ebay covers getting up and running. Here are a couple of handy calls to know:


$session = Services_Ebay::getSession($devId, $appId, $certId);
$session->setToken($token);

$call = Services_Ebay::loadAPICall('GetCategories');
$call->describeCall();
$result = $call->call($session);
print_r($result);

The describeCall() describes any method you care to load via loadAPICall() and you can see the complete list of methods in the package via getAvailableApiCalls()

The describeCall() output links to the eBay Developers documentation on the given call.

For example, getCategories() is documented here, which explains which parameters to pass to obtain the version number of the current category list and what to pass to dump the entire category tree.

One silly problem I ran into wass, how do I pass the parameters to the getCategory() call? It took me awhile because I couldn’t find it via googling so I had to experiment.

Turns out it’s


$session = Services_Ebay::getSession($devId, $appId, $certId);
$session->setToken($token);
$ebay = new Services_Ebay($session);

try {
$args = array(
'DetailLevel'=>1,
'ViewAllNodes'=>1,
);
$result = $ebay->GetCategories($args);
print_r($result);
} catch (Exception $e) {
echo "Something went wrong.";
echo $e;
}

If you’re going to cut your teeth on the getCategories() call like I did, remember to lift the default 8M memory limit on your script when you dump the entire tree.

So I’m looking forward to experimenting with this API.

Real Time Analytics