質問

私のコード:

  def start
    redirect_to client.authorization.authorize_url(:redirect_uri => callback_oauth_url,
                                                   :scope => "email,user_birthday,user_hometown,user_interests,user_location,user_notes,user_status,sms,publish_stream")
  end

  def callback
    access_token = client.authorization.process_callback params[:code], :redirect_uri => callback_oauth_url
    session[:access_token] = access_token
    render :json => client.selection.me.info! # <-- HERE IS THE ERROR >.<
  end

私は行きました /oauth/start/ サインインに成功し、アプリを許可しました。その後、Facebookは私をアプリにリダイレクトしました。これにより、このエラーが発生しました。

oauthcontrollerのnomethoderror#callback

undefined method `encode_json' for true:TrueClass

私たちは皆、エラーが嫌いなので、私もそうです。どうすればこれを修正できますか?ありがとう。

役に立ちましたか?

解決

info! メソッドはのインスタンスを返します FBGraph::Result, 、電話する必要があります data その上に、RailsがJSONにエンコードできるように。次のコードは私のために正常に機能します:

render :json => client.selection.me.info!.data
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top