Facebook像计数网址 [英] Facebook like count url

查看:156
本文介绍了Facebook像计数网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于Facebook更改了API并弃用了旧的API,因此我需要获取关于单个页面的数据(如计数,分享计数,评论数)。



我想出如何通过Facebook图获取数据(示例链接):

  https://graph.facebook.com/?fields=og_object {likes.limit(0)。总结(真)},份额&安培; IDS = HTTP://www.businessinsider.com/airlines-dont-披露承运人费用 - 夸张票价 -  2016-9 

但现在我不知道如何在php中回显单个数据(喜欢计数)。我尝试用json,但没有成功:

  $ json = file_get_contents($ xml); 
$ json_output = json_decode($ json);

任何建议如何使这项工作?

解决方案

API资源管理器会自动添加访问令牌,但您必须在URL中手动添加:

  https://graph.facebook.com/?fields=og_object {likes.limit(0)。总结(真)},份额&安培; IDS = HTTP://www.businessinsider.com/airlines-不透露运营商费用 - 充气票价格2016-9& access_token = xxx 

结果:

  {
http://www.businessinsider.com/airlines-dont-disclose- $ {
喜欢:{
data:[
] ,
summary:{
total_count:0,
can_like:true,
has_liked:false
}
}
id:949055545223224
},
share:{
comment_count:0,
shar e_count:346
},
id:http://www.businessinsider.com/airlines-dont-disclose-carrier-fee-that-inflates-ticket-prices-2016-9
}
}


As Facebook changed their API and deprecated the old one, I need to get data (likes count, share count, comment count) about single pages.

I figured out how to get data over Facebook graph (example link):

https://graph.facebook.com/?fields=og_object{likes.limit(0).summary(true)},share&ids=http://www.businessinsider.com/airlines-dont-disclose-carrier-fee-that-inflates-ticket-prices-2016-9

But now I don't know how to echo single data (likes count) in php. I tried with json, but had no sucsess:

$json = file_get_contents($xml);
$json_output = json_decode($json);

Any suggestions how to make this work?

解决方案

The API Explorer adds the Access Token automatically, but you have to add it manually in your URL:

https://graph.facebook.com/?fields=og_object{likes.limit(0).summary(true)},share&ids=http://www.businessinsider.com/airlines-dont-disclose-carrier-fee-that-inflates-ticket-prices-2016-9&access_token=xxx

Result:

{
  "http://www.businessinsider.com/airlines-dont-disclose-carrier-fee-that-inflates-ticket-prices-2016-9": {
    "og_object": {
      "likes": {
        "data": [
        ],
        "summary": {
          "total_count": 0,
          "can_like": true,
          "has_liked": false
        }
      },
      "id": "949055545223224"
    },
    "share": {
      "comment_count": 0,
      "share_count": 346
    },
    "id": "http://www.businessinsider.com/airlines-dont-disclose-carrier-fee-that-inflates-ticket-prices-2016-9"
  }
}

这篇关于Facebook像计数网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆