Book Image

PHP Web 2.0 Mashup Projects: Practical PHP Mashups with Google Maps, Flickr, Amazon, YouTube, MSN Search, Yahoo!

By : Shu-Wai Chow
Book Image

PHP Web 2.0 Mashup Projects: Practical PHP Mashups with Google Maps, Flickr, Amazon, YouTube, MSN Search, Yahoo!

By: Shu-Wai Chow

Overview of this book

A mashup is a web page or application that combines data from two or more external online sources into an integrated experience. This book is your entryway to the world of mashups and Web 2.0. You will create PHP projects that grab data from one place on the Web, mix it up with relevant information from another place on the Web and present it in a single application. This book is made up of five real-world PHP projects. Each project begins with an overview of the technologies and protocols needed for the project, and then dives straight into the tools used and details of creating the project: Look up products on Amazon.Com from their code in the Internet UPC database A fully customized search engine with MSN Search and Yahoo! A personal video jukebox with YouTube and Last.FM Deliver real-time traffic incident data via SMS and the California Highway Patrol! Display pictures sourced from Flickr in Google maps All the mashup applications used in the book are built upon free tools and are thoroughly explained. You will find all the source code used to build the mashups used in this book in the code download section for this book.
Table of Contents (11 chapters)

Working with REST in PHP


Like XML-RPC, we will need to create a REST request with PHP and use PHP to process the response. Unlike XML-RPC, there are no functions created specifically for REST, but that is not necessary. As REST uses just a simple HTTP request, we can use the existing network functions to make and capture the response. The results will come back in XML. We will look at two ways of processing it and turning into PHP data that we can use.

Making a REST Request

Like we talked about earlier, REST is basically like a web page request to the web server. It does not get any more glamorous than that. We will look at a couple of ways to initiate this hit.

A GET and POST Refresher

We constructed a POST request earlier in order to make our XML-RPC call. Let’s take a closer and quick look at the differences between a GET header and a POST header.

Here is a bare bones GET request

GET /aService.php?One=1&Two=2+and+2%25&Three=3 HTTP/1.0
Host: localhost
User-Agent: A PHP Client

There are...