Skip to Content
eBay Hacks, 2nd Edition
book

eBay Hacks, 2nd Edition

by David A. Karp
June 2005
Beginner
463 pages
14h 19m
English
O'Reilly Media, Inc.
Content preview from eBay Hacks, 2nd Edition

Search with PHP 5 and a Web Services Interface to the XML API

Connect PHP 5 to the eBay API with the Services_eBay PEAR package.

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 Schmidt, 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 Services_Ebay to 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.

Installation and Configuration ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

eBay Hacks

eBay Hacks

David A. Karp
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz

Publisher Resources

ISBN: 059610068XErrata Page