2015-10-19 76 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。** –

相關問題