簡體   English   中英

使用Omniauth-Facebook gem存儲user_likes

[英]Storing user_likes with the Omniauth-Facebook gem

有誰知道在Auth Hash中user_likes存儲在哪里?

我嘗試過不同的組合:

auth.extra.raw_info.user_likes
auth.extra.raw_info.likes

我獲得了許可,我只是不知道如何訪問user_likes數組。

Omniauth-Facebook的寶石

過了一段時間(編輯)

或者我可以使用HTTParty gem做這樣的事情:

  url = "https://graph.facebook.com/#{auth.uid}/likes&access_token=#{auth.credentials.token}"
  @likes = HTTParty.get(url)

但我真的想知道它是否可能通過omniauth身份驗證過程...

omn​​iauth-facebook gem使用/ me調用來填充raw_info哈希。 根據facebook文檔http://developers.facebook.com/docs/reference/api/user/ ,喜歡不包含在用戶對象中,但是可以通過調用https://graph.facebook.com來訪問/我/喜歡

希望這個反應盡管很晚,幫助那些試圖找出auth哈希對象的不同哈希內部的人(架構參考: https//github.com/intridea/omniauth/wiki/Auth-Hash-Schema

可以簡單地將對象渲染為瀏覽器的yaml,而不是嘗試不同的組合(如問題中所述)。 現在,瀏覽器輸出的頁面源將清楚地顯示auth對象的返回部分。 其他選項是調試中斷並檢查回調控制器中的auth對象(在這種情況下,ide會非常有用)。

的routes.rb

 ...
 match '/auth/facebook/callback' => 'authentications#create'
 ...

authentications_controller.rb(或接收回調的控制器)

class AuthenticationsController < ApplicationController
    ...


    def create
        # a simple code to understand the content of the auth object
        render :text => request.env["omniauth.auth"].to_yaml
    end
 end

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM