2013-03-30 27 views
3
https://graph.facebook.com/search?access_token=xxxxxx&q=hello&type=post&fields=from,message,picture,link,name,caption,description,created_time&limit=1&locale=en_US&scope=publish_stream,offline_access,user_status,read_stream 

這樣的圖搜索後,我得到這樣一些數據:如何在圖形搜索後獲取Facebook信息?

{ 
    "data": [ 
     { 
     "from": { 
      "name": "Eric Fluegge", 
      "id": "100000626293694" 
     }, 
     "message": "Well, here's go nothing. Hello Tennessee.", 
     "created_time": "2013-03-30T19:23:44+0000", 
     "id": "100000626293694_567340783296793" 
     } 
    ], 
    "paging": { 
     "previous": "https://graph.facebook.com/search?fields=from,message,picture,link,name,caption,description,created_time&q=hello&limit=1&type=post&locale=en_US&access_token=XXXXXXXXXXXXX&since=1364671424&__previous=1", 
     "next": "https://graph.facebook.com/search?fields=from,message,picture,link,name,caption,description,created_time&q=hello&limit=1&type=post&locale=en_US&access_token=XXXXXXXXXXXXX&until=1364671423" 
    } 
} 

如此,是"id": "100000626293694_567340783296793"後ID?如果是這樣,如何使用這個帖子ID,再次查詢,只有這個特定的帖子信息?我想將post id存儲到mysql表中,那麼我想在將來隨時查詢這篇文章,謝謝。

EIDT:在應用程序的設置,我已經設置了publish_stream,offline_access,user_status,read_stream

EIDT2: 我曾嘗試到Graph API Explorer,選擇read_stream並生成萬歲令牌。

SELECT post_id, actor_id, message, type, attachment FROM stream WHERE post_id = "100000626293694_567340783296793" 

結果仍爲空。所以我找不到帖子,因爲我不是帖子作者的朋友?或者100000626293694_567340783296793不是帖子ID?或其他原因?

+1

** ** offline_access現在已經貶值。 –

+2

事實上,它已被長期生存的access_tokens取代。 –

回答

2

是的,在"id": "100000626293694_567340783296793"是一個帖子的ID,就可以查詢它的數據再次與以下網址:http://graph.facebook.com/100000626293694_567340783296793

注意!

你應該問的read_stream許可/範圍呢!否則你會得到以下錯誤:

{ 
    "error": { 
     "message": "Unsupported get request.", 
     "type": "GraphMethodException", 
     "code": 100 
    } 
} 

當然,追加access_token到您的GET網址。 (不要忘了HTTPS也是如此)

你可以在這裏查看圖形API參考:Post - Facebook Developer Reference

+0

https://developers.facebook.com/tools/explorer?fql=SELECT%20post_id%2C%20actor_id%2C%20message%2C%20type%2C%20attachment%20FROM%20stream%20WHERE%20post_id%20%3D%20 %22100000626293694_567340783296793%22,仍然沒有任何回報。你能在你的測試中得到數據嗎?我用'長壽命的access_tokens'設置了'read_stream'。謝謝。 –

+2

使用您自己的令牌,您將永遠無法訪問該帖子。如果帖子未公開,您必須使用您的用戶令牌。 –

+0

@fishman是否嘗試使用App Access令牌或用戶訪問令牌進行搜索?我在這裏發現了一個奇怪的事情,如果您使用用戶訪問令牌搜索,您會得到不同的結果,並且可以進一步查詢帖子。你試過這個嗎? –