Fra*_* M. 5 facebook facebook-graph-api
我正在尝试访问给定URL在Facebook上收到的喜欢,分享和评论的数量.
据我理解这篇文档,以下URL应该给我我想要的东西.
https://graph.facebook.com/v2.4?id=http://stackoverflow.com&fields=og_object,share&access_token=MY_ACCESS_TOKEN
Run Code Online (Sandbox Code Playgroud)
它给了我以下内容:
{
"og_object": {
"id": "10150180465825637",
"description": "Q&A for professional and enthusiast programmers",
"title": "Stack Overflow",
"type": "website",
"updated_time": "2015-08-02T04:03:47+0000",
"url": "http://stackoverflow.com/"
},
"share": {
"comment_count": 4,
"share_count": 32567
},
"id": "http://stackoverflow.com"
}
Run Code Online (Sandbox Code Playgroud)
其中包括comment_count = 4和share_count = 32567.
但是,如果我参考之前链接的文档,喜欢的数量应该出现在"og_object":应该有engagement一行内有两个元素,count(喜欢的数量)和social_sentence(一个社交句子,如"你和31,608,561其他人喜欢"这个.")
显然,这些engagement和count元素都不存在.我怎么能让它们出现?
注意:在第一个URL中,我尝试更改&fields=og_object,share以下任何一个部分:
&fields=og_object.engagement,share
&fields=og_object.engagement.count,share
&fields=og_object,engagement,share
&fields=og_object,engagement,share
&fields=engagement,share
&fields=engagement.count,share
&fields=engagement,count,share
&fields=count,share
(NB : I also tried by putting `share` first in the list)
Run Code Online (Sandbox Code Playgroud)
但是没有一个工作,我总是得到一个错误,比如这个(每次尝试包括一个.):
{
"error": {
"message": "Syntax error \"Expected \"(\" instead of \",\".\" at character 20: og_object.engagement,share",
"type": "OAuthException",
"code": 2500
}
}
Run Code Online (Sandbox Code Playgroud)
或者这一个(每次尝试没有.:
{
"error": {
"message": "(#100) Tried accessing nonexisting field (engagement) on node type (URL)",
"type": "OAuthException",
"code": 100
}
}
Run Code Online (Sandbox Code Playgroud)
Fra*_* M. 11
感谢@WizKid,答案是
https://graph.facebook.com/v2.4?id=http://stackoverflow.com&fields=og_object{engagement},share&access_token=
Run Code Online (Sandbox Code Playgroud)
要么
https://graph.facebook.com/v2.4?id=http://stackoverflow.com&fields=og_object{engagement{count}},share&access_token=
Run Code Online (Sandbox Code Playgroud)
但是,og_object{engagement{count}}并share_count显示相同的数字...这等于total_count使用旧的时候(和不推荐的)
http://api.facebook.com/restserver.php?method=links.getStats&format=json&urls=h??ttp://stackoverflow.com/
Run Code Online (Sandbox Code Playgroud)
似乎没有办法通过图表api获得喜欢的数量和份额...
| 归档时间: |
|
| 查看次数: |
2397 次 |
| 最近记录: |