As Facebook changed their API and deprecated the old one, I need to get data (likes count, share count, comment count) about single pages.
I figured out how to get data over Facebook graph (example link):
https://graph.facebook.com/?fields=og_object{likes.limit(0).summary(true)},share&ids=http://www.businessinsider.com/airlines-dont-disclose-carrier-fee-that-inflates-ticket-prices-2016-9
But now I don’t know how to echo single data (likes count) in php. I tried with json, but had no sucsess:
$json = file_get_contents($xml);
$json_output = json_decode($json);
Any suggestions how to make this work?
2
Answers
The results of json_decode() are Objects.
So you can easily browse through like this:
The API Explorer adds the Access Token automatically, but you have to add it manually in your URL:
Result: