问题
My idea is to implement something like this:
http://i.imgur.com/MHJrY.png
screenshot is from here: http://www.thedrum.co.uk/opinion/2012/03/08/five-ways-new-facebook-timeline-will-impact-brands
I've read that I have to use either Facebook graph API or FQL but I don't know which one is the best.
This is what I have so far but it takes a long to do it so my guess is that is the wrong method:
<? require_once 'libs/facebook.php';
// Create our Application instance.
$facebook = new Facebook(array(
'appId' => 'appid',
'secret' => 'secret',
'cookie' => true,
));
$result = $facebook->api(array(
'method' => 'fql.query',
'query' => 'SELECT share_count, like_count, comment_count, total_count FROM link_stat WHERE url="URL";'
));
echo '<p>'.$result[0]['like_count'].' likes';
?>
Is it OK if I try to get the share count (using one of the methods mentioned before) of let's say 50 different posts I have on my home page? Doesn't Facebook have a limit for this?
回答1:
Use the graph API. FQL still works but it isn't one of Facebook's priorities.
Here is the link so you can see how it works: https://developers.facebook.com/docs/reference/api/
Secondly buffer the number so you aren't hitting Facebook everytime and will get faster page loads on your end.
来源:https://stackoverflow.com/questions/9652491/can-i-get-lots-of-share-counts-using-facebook-graph-api-and-how-to-do-it