2013-04-15 19 views
1

我有一個幫手。獲取Facebook粉絲頁面的列表。前幾天上班,突然停了下來。我收到一個fanpage後停止。我得到這個錯誤:獲取Facebook頁面的列表GEM考拉

type: OAuthException, code: 100, message: (#100) Invalid Connection [HTTP 400] 

這是幫助我的

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 

別人也有類似的問題。如何解決它?

回答

0

聽起來像您的訪問令牌已過期。它們不會持續很長時間。我猜你幾天前將它保存在數據庫中,並且它工作了一段時間,但後來過期了。幾乎每個會話都需要獲取新的訪問令牌,並在數據庫中對其進行更新。

+0

variables @ graphs,@ url我做了數組,它的工作原理... –