我试图访问给定网址在Facebook上收到的喜欢,分享和评论的数量。
据我了解this piece of doc,以下网址应该可以提供我想要的内容。
https://graph.facebook.com/v2.4?id=http://stackoverflow.com&fields=og_object,share&access_token=MY_ACCESS_TOKEN
它给了我以下内容:
{
"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"
}
包括comment_count = 4和share_count = 32567.
但是,如果我引用previously linked piece of doc,则相似的数量应显示在"og_object"
中:应该有engagement
行,其中包含两个元素,count
(喜欢的数量)和social_sentence
(社交句子如"你和31,608,561其他人喜欢这样。")
显然,这些engagement
和count
元素不存在。我怎么能让他们出现?
注意:在第一个网址中,我尝试更改其中任何一个的&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)
但是没有一个工作,我总是得到一个错误,比如这个(每次尝试都包含.
):
{
"error": {
"message": "Syntax error \"Expected \"(\" instead of \",\".\" at character 20: og_object.engagement,share",
"type": "OAuthException",
"code": 2500
}
}
或这一个(每次尝试没有.
:
{
"error": {
"message": "(#100) Tried accessing nonexisting field (engagement) on node type (URL)",
"type": "OAuthException",
"code": 100
}
}
答案 0 :(得分:11)
感谢@WizKid,答案是
https://graph.facebook.com/v2.4?id=http://stackoverflow.com&fields=og_object{engagement},share&access_token=
或
https://graph.facebook.com/v2.4?id=http://stackoverflow.com&fields=og_object{engagement{count}},share&access_token=
但是,og_object{engagement{count}}
和share_count
显示相同的数字...当使用旧的(并且已弃用)时,它等于total_count
http://api.facebook.com/restserver.php?method=links.getStats&format=json&urls=http://stackoverflow.com/
似乎没有办法通过图表api获得喜欢的数量和份额...