我想从ruby脚本检查另一个页面的facebook状态。首先是可能的。我一直在做以下事情:
这是我的代码:
require 'rubygems' require 'json/pure' require 'net/http' url ="https://graph.facebook.com/user_id/feed?access_token=app_id|app_secret" uri = URI.parse(URI.encode(url.strip)) #to remove specia codes encode #to remoce whitespace strip req = Net::HTTP::Get.new(uri.to_s) res = Net::HTTP.start(uri.host, uri.port) {|http| http.request(req) } html = res.body res = JSON.parse(html)
以下是错误:
C:/Ruby187/lib/ruby/1.8/net/protocol.rb:135:in `sysread': An existing connection
was forcibly closed by the remote host. (Errno::ECONNRESET)
答案 0 :(得分:1)
我建议使用koala gem代替Net::Http
@graph = Koala::Facebook::API.new(oauth_access_token)
status = @graph.get_connections("me", user_id, "status")