2015-10-19 75 views
0

我使用Facebook图表api获取博客的股份数量和评论,但有时它不返回股票和评论。Facebook API无法为某些URL工作

以下URL没有给出共享和评论的数量。

http://graph.facebook.com/?id=http://www.lehedonist.com/jeans-is-the-new-whiskey-2001

,但它正在为这个网址:

例子:http://graph.facebook.com/?id=http://www.lehedonist.com/spring-slam-fashion-war-ss16-1965

+0

它是安全的假设,如果不存在这些领域,有0股/评论? –

+0

之前显示的是共享和评论,但突然没有显示。 –

+0

如果它显示“股份”:0,“评论”:0'之前,那么我怀疑这将是一个Facebook API的变化。如果我去那个网站并使用一篇没有评论的文章,​​但是有一些分享,它确实给出了分享领域,但没有评论领域。 –

回答

0

我有点不知道为什么它甚至努力要求这些网址,没有一个访问令牌是诚实的。

它只是给出了一个结果,如果有在URL中没有版本信息。要做到这一点在V2.5方式不当,你就必须使用

https://graph.facebook.com/v2.5/?access_token={access_token}&fields=id,og_object,share&id=http://www.lehedonist.com/spring-slam-fashion-war-ss16-1965 

其中{access_token}是一个实际的访问令牌。

结果会像

{ 
    "id": "http://www.lehedonist.com/spring-slam-fashion-war-ss16-1965", 
    "og_object": { 
     "id": "987675524635070", 
     "description": "Not your usual fashion post, we decode styles best suited to your personality and what should you be sporting next summer", 
     "title": "Spring Summer 16 fashion: The clash of fashion personalities", 
     "type": "article", 
     "updated_time": "2015-10-08T11:24:32+0000", 
     "url": "http://www.lehedonist.com/spring-slam-fashion-war-ss16-1965" 
    }, 
    "share": { 
     "comment_count": 2, 
     "share_count": 81 
    } 
} 
+0

你是生命的救星,只有一个问题,如何生成访问令牌? –

+0

https://developers.facebook.com/docs/facebook-login/access-tokens#apptokens – Tobi

+0

现在我得到这个错误: **未知的字段:og_object。** –

相关问题