2011-08-23 53 views
2

我想獲得的一個URL Facebook的評論列表。例如,我有URL「http://example.com/37」通過圖形API的探險家,我只需要將該URL參數「https://graph.facebook.com/comments/?ids=http:example.com/35「。我如何使用考拉寶石來做到這一點?獲得一個網址的評論 - 考拉圖形API

感謝,

回答

1

我覺得考拉不使這一儘可能直觀,因爲它需要一個訪問令牌 - 不像直接訪問圖形API。另外,它似乎需要一組URL。

urls  = ["http://example.com/37"] 
graph = Koala::Facebook::GraphAPI.new(some_access_token) 
comments = graph.get_comments_for_urls(urls) 
2

爲了澄清以前的答案有點...考拉的文檔指出get_comments_for_urls方法fetches the comments from fb:comments widgets for a given set of URLs (array or comma-separated string)。所以,當有一個頁面上的實際Facebook的評論框(:https://developers.facebook.com/docs/reference/plugins/comments/詳見這裏)這個調用工作。

這裏是一個真正的URL工作的例子:

oauth   = Koala::Facebook::OAuth.new Facebook::APP_ID, Facebook::SECRET 
app_access_token = oauth.get_app_access_token 
graph   = Koala::Facebook::API.new app_access_token 
urls    = ['http://www.ruhanirabin.com/easy-steps-to-facebook-connect-comment-box-how-to/'] 
comments   = graph.get_comments_for_urls(urls) 

請注意,App訪問令牌是從應用程序ID不同,祕密Facebook的開發者網站應用程式設定中指定。