0

Facebook に投稿する Rails アプリケーションがあります。同じメッセージを 2 回投稿するエラーを防ぐためのレスキューを行いました。アプリでユーザーに通知して先に進みたいのですが、このエラーを解決できないようです。

これは私のコードです:

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) ステータス メッセージが重複しています

4

2 に答える 2

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)
于 2011-12-12T18:21:35.500 に答える
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
于 2012-03-06T17:39:18.140 に答える