Dan
Dan

Reputation: 12096

How do I get individual Json data from a facebook graph call?

Im trying to get shares count from this Facebook graph call using php but am having no luck:

http://graph.facebook.com/?ids=http://google.com

Try 1

$content = file_get_contents("http://graph.facebook.com/?ids=http://google.com");
$parsedJson = json_decode($content, true);
echo $parsedJson['shares'];

Try 2

$content = file_get_contents("http://graph.facebook.com/?ids=http://google.com");
$parsedJson = json_decode($content, true);
echo $parsedJson->shares;

What am I doing wrong?

Upvotes: 0

Views: 64

Answers (2)

Kirk Backus
Kirk Backus

Reputation: 4866

This will work!

echo ($parsedJson->{'http://google.com'}->shares);

Upvotes: 0

rcambrj
rcambrj

Reputation: 602

try

echo $parsedJson["http://google.com"]['shares'];

Upvotes: 2

Related Questions