Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to parse a Google+ (Google Plus) profile page?

If you view the source of a Google+ profile page, it appears rather complex. It seems most of the data is kept in a huge JSON-like objects. However, they don't seem to be really JSON, since they don't get recognized when I try to decode them. I am hoping the format is more clear to other people here. How would you go about parsing it? It seems it would fairly trivial, if you know where to start.

Here is a sample profile, for example: http://plus.google.com/104560124403688998123

like image 871
burger Avatar asked Feb 23 '23 16:02

burger


1 Answers

Here's a PHP API I'm working on. It can download and parse the data for a profile page and people's public relationships.

https://github.com/jmstriegel/php.googleplusapi

The JSON piece is a bit mangled. To generate valid JSON, you basically have to remove the first 5 characters that prevent XSRF attacks and then add in all the nulls that have been removed. Here's the code specific to handling parsing the weird Google Plus JSON responses:

https://github.com/jmstriegel/php.googleplusapi/blob/master/lib/GooglePlus/GoogleUtil.php

Call GoogleUtil::FetchGoogleJSON( $url ) and you'll get back a giant array that you can then pull data from. Using this, it should be trivial to make a proxy service to translate stuff into valid json(p) for you to use in your own apps.

like image 120
Jason Striegel Avatar answered Mar 05 '23 04:03

Jason Striegel