Google APIs Client Library for PHP (Beta)

SEP 08, 2011

By Chirag Shah, Developer Programs Engineer

Today we are announcing a major milestone for another one of the Google APIs client libraries. The Google APIs Client Library for PHP has officially reached Beta.

This means we're comfortable enough with the stability and features of the library that we'd like you to start building real production applications on top of it and send us your feedback. The library now includes service-specific libraries and samples for several Google APIs, built on our new client library generation infrastructure.

The Google API PHP client supports the following Google APIs right now, with more on the way.
To grab the latest version of the library, simply run the following commands:
curl
      "http://google-api-php-client.googlecode.com/files/google-api-php-client-0.4.1.tar.gz"
      -O
tar -xvf google-api-php-client-0.4.1.tar.gz
cd google-api-php-client/examples/
Here is some sample code that demonstrates how to use the library and the Google Books API to search for and print the titles of free ebooks by Henry David Thoreau:
<?php
require_once 'path/to/src/apiClient.php';
require_once 'path/to/src/contrib/apiBooksService.php';

$client = new apiClient();
$client->setApplicationName("My_Books_API_Example");
$service = new apiBooksService($client);

$optParams = array('filter' => 'free-ebooks');
$results = $service->volumes->listVolumes('Henry David Thoreau', $optParams);

foreach ($results['items'] as $item) {
print($item['volumeInfo']['title'] . '<br>');
}
Let us know what you think. We would love to hear your feedback and are always happy to help you out on the forums.

Since Google I/O 2010, we've been developing APIs that can provide descriptions of themselves via metadata. This new technique makes it easier to create and maintain client libraries that support more languages, work with more APIs, and are easier to use than ever before. This post announces one of several recent major milestones for our client libraries.


Chirag Shah is a Developer Programs Engineer on the Google+ team.
In his spare time, he enjoys listening to music and contributing to open source projects.


Posted by Scott Knaster, Editor