Get JSON response from facebook api restserver
I want to get the like_count of a page. I tried using PHP SDK, but I've given up on it because my site always stops loading after the line of code where the FQL query is executed, so I wanted to try to get the like count 'manually'.
I tried using file_get_contents() on https://api.facebook.com/restserver.php?method=fql.query&query=QUERY&format=json, but it shows me nothing.
开发者_如何学PythonDo you know how I can get the JSON string from the above URL on which I can use json_decode(), or even a better way to get the like count?
Any help is appreciated.
PS If it means anything, QUERY is SELECT like_count FROM link_stat WHERE url="page_url_here"
Your FQL should be encoded, and you can use new url address:
https://api.facebook.com/method/fql.query?query=SELECT%20like_count%20FROM%20link_stat%20WHERE%20url%3D%22http%3A%2F%2Fsample.com%22&format=json&access_token=<ACCESS_TOKEN>
精彩评论