2017-01-16 118 views
-2

當我試圖獲取評論時,我收到此錯誤消息。如何使用HttParty獲得Facebook評論

article_url = "http://de.richarddawkins.net/articles/atheist-stephen-hawking-negiert-existenz-eines-gottes-die-wissenschaft-biete-eine-uberzeugendere-erklarung-des-universums" 

HTTParty.get("https://graph.facebook.com/comments?id=#{article_url}") 

#<HTTParty::Response:0xb4fa49c parsed_response={"error"=>{"message"=>"An access token is required to request this resource.", "type"=>"OAuthException", "code"=>104, "fbtrace_id"=>"Asfda7D+/qM"}}, @response=#<Net::HTTPBadRequest 400 Bad Request readbody=true>, @headers={"www-authenticate"=>["OAuth \"Facebook Platform\" \"invalid_token\" \"An access token is required to request this resource.\""], "access-control-allow-origin"=>["*"], "pragma"=>["no-cache"], "cache-control"=>["no-store"], "facebook-api-version"=>["v2.2"], "expires"=>["Sat, 01 Jan 2000 00:00:00 GMT"], "content-type"=>["application/json; charset=UTF-8"], "x-fb-trace-id"=>["Asfda7D+/qM"], "x-fb-rev"=>["2778708"], "vary"=>["Accept-Encoding"], "x-fb-debug"=>["pSZo8HXiIaM0tu9f0ss+swqnhShjgCQYpm3GN8GQS+olRNjmwTfiHPPE/8xZJRxu787j7JlwCHW9kwuayjcgeA=="], "date"=>["Mon, 16 Jan 2017 06:23:43 GMT"], "connection"=>["close"], "content-length"=>["139"]}> 

請幫我解決這個問題。

回答

0

我想你只需要將ACCESS_TOKEN添加到你的查詢字符串。

Ex。

HTTParty.get("https://graph.facebook.com/comments?id=#{article_url}&access_token=#{ACCESS_TOKEN}") 

希望它的工作

+0

我如何獲得訪問令牌? –

+0

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

+0

它是否適用於localhost:3000? –

相關問題