【问题标题】:Retrieve friends education_history from Facebook using koala Ruby gem使用 koala Ruby gem 从 Facebook 检索朋友的education_history
【发布时间】:2012-07-09 15:00:06
【问题描述】:

我想检索用户朋友education_history,我正在使用koala gem 和rubyonrails。

我在omniauth的初始化文件中添加了获取用户朋友education_history的权限::scope => 'user_education_history,friends_education_history

到目前为止,我可以获取用户朋友 :name 和 :id,但不知道如何获取用户朋友 education_history。

def add_friends
    facebook.get_connections("me", "friends").each do |hash|
      self.friends.where(:name => hash['name'], :uid => hash['id']).first_or_create
    end
end

有什么想法吗?

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-3 koala fb-graph


    【解决方案1】:

    我通过使用考拉提供的字段键解决了我的问题,它更高效,工作更快:

    def add_friends
        facebook.get_connections("me", "friends", :fields => "name, id, education").each do |hash|
          self.friends.where(:name => hash['name'], :uid => hash['id'], :highschool_name => hash['education'][0]['school']['name'], :graduateschool_name => hash['education'][1]['school']['name']).first_or_create
        end
      end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-06
      • 1970-01-01
      • 1970-01-01
      • 2012-02-15
      • 2013-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多