Connect PHP 5 to the eBay API with
Like many web services, the eBay API comes in multiple flavors. There's the original XML-over-HTTPS POST interface used by most of the hacks in this chapter, a format that's quite similar to REST [Hack #107] . There's also a newer, more fashionable SOAP interface, which uses the Doc/Literal format.
Both have benefits and weaknesses. Pure XML is easy to produce and consume on any platform, something that's vital given the shaky state of PHP's SOAP support. However, SOAP has the advantage of eliminating the trouble of manually parsing XML into usable data structures.
PHP programmers have a third alternative, which combines the best
parts of both interfaces:
Services_Ebay. Written primarily by Stephan
Services_Ebay is a PEAR
package that wraps around the XML API to provide an object-oriented
interface to eBay. Additionally, it takes advantage of several new PHP 5
features to create powerful code that's simple to use. You can't run
this code under PHP 4 because PHP 5 plays such a key role.
This hack uses
search eBay and display results, similar to what an eBay affiliate might
write. In the process, it gives a small taste of what you can begin to
do with the package. Additionally, it shows off a real-world
implementation of a PHP 5 program, one that showcases many of the
reasons to upgrade from PHP 4 to PHP 5.