Search code examples
phpregexsocial-networkingjson

Google social Graph response decode


I would like make a script that automatically insert in a Array the Google+ ID's fetched from the SocialGraphs Api but i can't understand the type of this result,here's the example of the result: http://pastebin.com/wfBAtjH7

If can be help,i've seen the method for isolate the ID's done in Javascript:

var oids = [];
var reobg = new RegExp("\\d{21}","g"); // only interested in user ID so prepare regexp
oids = resp.match(reobg); // get an array of ids
if (!oids == null){ // if something stringify it
   oids = oids.join(",");
}

For get in a variable all the text,i've used this code:

$gplus = file_get_contents('https://plus.google.com/u/0/_/socialgraph/lookup/visible/?o=[null,null,"103227580967788703328"]&rt=j');

Where 103227580967788703328 is an example Google Plus ID.

Thanks in advance.

Kind Regards.

Luca.


Solution

  • Try and cycle through the input with this regex:

    \[\[,,"(\d+)"\]
    

    and grab the first group each time.