I have a helper. Gets a list of the facebook fanpage. A few days ago to work, suddenly stopped. I stop after taking one fanpage. I get this error:
type: OAuthException, code: 100, message: (#100) Invalid Connection [HTTP 400]
This is my helper
def self.download_fanpages(user_id)
#API Facebook
@graph = Koala::Facebook::API.new(Client.find(user_id).access_token.to_s)
#download list of fanpage
for facebook_page in @graph.get_object("me/accounts/page")
@graphs = Koala::Facebook::API.new(facebook_page["access_token"])
@url = @graphs.get_object("me")
if @url['link'].index("facebook")
if !Fanpage.find_by_uid_and_user(facebook_page["id"],user_id)
@fb = Fanpage.new
@fb.user = user_id
else
@fb = Fanpage.find_by_uid(facebook_page["id"])
end
@fb.name = facebook_page["name"]
@fb.access_token = facebook_page["access_token"]
@fb.uid = facebook_page["id"]
@fb.url = @url['link']
#install or not install
if @graphs.get_object("me/tabs/"+APP_ID.to_s).count > 0
@fb.install = 1
else
@fb.install = 0
end
@fb.save
end
end
end
Does anyone else have a similar problem. How to solve it?
Sounds like your access token expired. They don't last very long. I'm guessing you saved it in your database a couple days ago, and it worked for a while but then expired. You need to fetch a new access token pretty much every session, and update it in your database.