Professional Web APIs with PHP
Professional Web APIs with PHP by Paul Reinheimer is a book that I first got a glimpse of at the Vancouver PHP Conference last spring. Alas, I didn't have any cash on me to pick it up, but I promised Paul that I would buy it through his website so he could pick up the Amazon sales commission. Unfortunately, when I went to buy the book, I found his website unavailable. Paul, I owe you a beer to make up for that!
I'm a big fan of the Wrox Programmer to Programmer book series. The structure of these books allows for at-a-glance learning that enables you to hit the ground running. Professional Web APIs with PHP is no exception. This book covers PHP development using the eBay, Google, PayPal, Amazon, and FedEx APIs, and also features a primer on web feeds. Because the book is broken up by API, you don't have to read this cover to cover and can instead just review the APIs that you plan to develop with.
I would recommend reading Part One in it's entirety, which provides an introduction on web services, and then covers RSS and Atom web feeds over the next three chapters. Developers who already have this knowledge can skip ahead, though I found Part One to be a good read despite already having experience in this area. By the nature of my own business, I often dive into code before reading much theory (a method sometimes referred to as "ass backwards"), so there's always more I can learn from these crash course style chapters.
Part Two is where we find the "meat" of this book. The introductory chapter reviews the REST and SOAP implementations, and offers several points for consideration in choosing which method to use in your applications, including overhead, transparency, ease of use, service definition, and encapsulation. (Of course, the choice between REST and SOAP is often made for you by the service you are working with.) Paul provides numerous clear code examples to get you up and running quickly, regardless of which method you choose, including manual SOAP requests and generation with the NuSOAP module.
The first API covered is Google Search using SOAP. There are plenty of ready to use code examples, including an SEO keyword and positioning monitoring tool.
Amazon web services is up next. Amazon is unique in that both REST and SOAP implementations are available to connect to their API. Example applications include searching Amazon by keyword or author, monitoring prices and sales ranks, and creating a personal store front.
The next chapter on FedEx provides code examples for integrating shipping into an e-commerce application, and also highlights some of the issues that Paul ran into developing for this API due to his location in Canada. I appreciated the tips and pointers in this area since I too am located in the Great White North.
eBay web services represents a way that developers can monetize their web sites by accessing the huge inventory of the International auction house. The eBay API is dense and thorough, offering both REST and SOAP, making Paul's clear guidance even more valuable. By the end of the chapter, you will be able search items, filter and display results, and list items for sale. These functions are just the basics—there's a lot you can do with the eBay API, but this introduction will get you up to speed on the basics and give you a foundation for more involved development using eBay web services.
Interacting with the PayPal API is the subject of the next chapter. Paul provides an overview of the API, and the development sandbox, and covers accepting payments, encryption, Instant Payment Notification, searching and retrieving transactions, issuing refunds, and how to use MassPay. PayPal's API introduces some new challenges with client-side certificates, but these are easily overcome with cURL and PayPal's strong SOAP design.
Chapter 11 covers the basics of three other web services: the National Weather Service, Flickr, and Del.icio.us. (Note that Wrox also has books in the Programmer to Programmer series dedicated to Flickr and Del.icio.us alone, and these are worth picking up if you'd like to learn more.)
The final chapter changes the focus from developing for APIs to developing your own APIs. Paul highlights the technical considerations that should go into planning your API, enabling authentication and encryption, choosing between REST and SOAP, working with the development community that will be accessing your web service, performance and error handling.
While Professional Web APIs with PHP doesn't go into extreme depth on any one API, this is an excellent review of the more popular web services that should probably be on the bookshelf of just about any PHP Web 2.0 developer.















