Skip to content

How to display latest Google+ updates with PHP and Unofficial Google+ API

As we are all waiting for official Google Plus API, I browsed the internet looking for some unofficial ways for implementing Google Plus into web applications.

I found some very interesting stuff, but the most advanced is Jason Striegel’s Unofficial Google API.

For the moment it consists the following:

GoogleUtil – functions for parsing the almost-JSON that Google Plus produces
PlusPerson – a person entity in Google plus that can be stored to a local mysql DB
PlusRelationship – a relationship between people in Google plus. This does not contain any circle context
PlusPost – a post to a user’s activity stream
PostAttachment – encapsulates a media attachment to a post

I will surely write a tutorial using this great code, but as I am enjoying a summer vacation, I wanted to write a simple tip on getting the latest updates from Google Plus. So I will use Plus Feed, an unofficial Google+ User Feeds.

Usage is pretty straightforward:

[code lang=”php”]

// Google Plus user id
$user_id = "107308413755179474011";
// we are using CURL to access the API
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://plusfeed.appspot.com/" . urlencode($user_id));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec ($curl);
curl_close ($curl);

header(‘Content-Type: application/xml; charset=UTF-8’);
// just echoing plain XML result (which is Atom feed)
echo $result;

[/code]

That’s it, you just enter desired Google Plus user id and get (unfortunately only public) updates for that user id. Now, you can use SimpleXMLElement to parse the results as I did on my Useful Twitter snippets tutorial.

More on this subject in one of the later tutorials, so stay tuned.