2011-12-12 37 views
0

我有一個Rails應用程序發佈到Facebook。爲了防止兩次發佈相同消息的錯誤,我進行了救援。我想讓我的應用程序只是通知用戶並繼續前進,但似乎無法挽救此錯誤。Ruby on Rails Facebook Graph API OAuth錯誤#506重複的狀態消息

這是我的代碼:

begin 
    current_user.facebook.feed!(:message => 'THIS IS A TEST PLEASE IGNORE::Hello, Facebook!') 
rescue FbGraph::Unauthorized 
    flash[:alert] = "Already Posted" 
end 
redirect_to show(@track) 

我此代碼得到的錯誤是:

OAuthException ::(#506)複製狀態消息

回答

1

爲什麼搶救從FbGraph::Unauthorized當你收到OAuthException錯誤?

begin 
    current_user.facebook.feed!(:message => 'THIS IS A TEST PLEASE IGNORE::Hello, Facebook!') 
rescue OAuthException 
    flash[:alert] = "Already Posted" 
end 
redirect_to show(@track) 
+0

我無法得到它與OAuthException或異常:: OAuthException工作。他們說未知的例外,但我只是救了所有例外 – richsoni

0

嘗試:

begin 
    current_user.facebook.feed!(:message => 'THIS IS A TEST PLEASE IGNORE::Hello, Facebook!') 
rescue => e 
    if(e.fb_error_type == "OAuthException" 
    flash[:alert] = "Already Posted" 
    end 
end