问题描述:

I have a simple action for auto posting data on Facebook, it's something like this:

pages = FbGraph::User.me(temp_token).accounts

page = pages.detect do |page|

if page.identifier == my_page

page.feed!(

:message => "a title",

:link => 'a link',

:description => "a description",

:picture => 'an image'

)

end

break

end

I am thinking how to get new token - I've tried something like this:

require 'net/http'

temp_token = 'the current access token'

looky_co_app_id = 'APP_ID'

looky_co_app_secret = 'APP_SECRET'

puts "https://graph.facebook.com/oauth/access_token?client_id=#{looky_co_app_id}&client_secret=#{looky_co_app_secret}&grant_type=fb_exchange_token&fb_exchange_token=#{temp_token}"

url = URI.parse("https://graph.facebook.com/oauth/access_token?client_id=#{looky_co_app_id}&client_secret=#{looky_co_app_secret}&grant_type=fb_exchange_token&fb_exchange_token=#{temp_token}")

req = Net::HTTP::Get.new(url.path)

res = Net::HTTP.start(url.host, url.port) {|http|

http.request(req)

}

puts res.body

But I get the error like this:

Errno::ECONNRESET in my_controller_name#the_action

Connection reset by peer

I am not sure if I am doing it right, but how to correctly renew the access token?

相关阅读:
Top