0

我想检索用户朋友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

有任何想法吗?

4

1 回答 1

2

我通过使用考拉提供的字段键解决了我的问题,它更高效且运行速度更快:

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
于 2012-07-09T19:51:36.537 回答