Facebook喜欢域中的多个页面

时间:2012-05-15 22:55:49

标签: facebook facebook-graph-api facebook-like

要解决的问题:

  1. 想象一下,我在http://my-awesome-site
  2. 有一个域名和相应的网站
  3. 在这个网站上我有10,000页。
  4. 每个页面都有一个Facebook赞按钮。
  5. 如何从Facebook Graph中检索每页的喜欢数量?
  6. 可以使用简单的GET请求查找每个网址的总喜欢数量(示例:google.comgoogle.com/readernews.google.com)。但是,是否有可能获得整个域的类似列表,按页面细分?结果如:

    {
       "id": "http://my-awesome-site/",
       "shares": 12345
    },
    {
       "id": "http://my-awesome-site/page1.html",
       "shares": 5678
    },
    
    ....
    
    {
       "id": "http://my-awesome-site/page10000.html",
       "shares": 9012
    }
    

2 个答案:

答案 0 :(得分:1)

我认为你能做的最好的事情是(使用link_stat table):

SELECT url, share_count
FROM link_stat
WHERE url IN ("http://my-awesome-site/", "http://my-awesome-site/page1.html"...)

但如果您有10,000页,则必须将其分成多个请求。 但是,您可以使用Batch Requests api然后合并一些请求。

如果这就是你所追求的那样,该解决方案应该大大降低http请求的数量。

答案 1 :(得分:1)

你也可以通过脸谱图来做到这一点 用逗号分隔的ids

https://graph.facebook.com/?ids=http://techcrunch.com,http://mashable.com

结果将是一个json,如下所示

{
   "http://mashable.com": {
  "id": "http://mashable.com",
  "shares": 14436 
},
"http://techcrunch.com": {
   "id": "http://techcrunch.com",
  "shares": 2144
}
}