我在Facebook上自动发布数据的操作很简单,就像这样:
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
我正在考虑如何获得新的令牌 - 我尝试过这样的事情:
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
但我得到的错误是这样的:
Errno::ECONNRESET in my_controller_name#the_action
Connection reset by peer
我不确定我是否正确行事,但如何正确续订访问令牌?