2014/09/10

[Facebook][JavaScript]Like数を取得する

Graph APIを使っていいねの数を取得することはできるのだろうか?

答えはできるみたい。
Get FB likes count for specific URL and page
よると

https://graph.facebook.com/?ids=http://www.your-website.com/the-url-or-so
というようにURLをたたけばでるようなのだが、

URL /?id={url}を読むと下のように組んでもよさそうだ。
FB.api(
    "/?id=http%3A%2F%2Fwww.imdb.com%2Ftitle%2Ftt2015381%2F",
    function (response) {
      if (response && !response.error) {
        response.shares
      }
    }
);

0 コメント:

コメントを投稿