Can i get lots of share counts using facebook graph API? And how to do it

谁说胖子不能爱 提交于 2020-01-06 08:01:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!