我想检索一个用户的朋友education_history,我正在使用考拉宝石和rubyonrails。
我已经为omniauth::scope => 'user_education_history,friends_education_history在我的初始化器文件中添加了获取用户朋友education_history的权限
到目前为止,我可以获得用户friend :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有什么想法吗?
发布于 2012-07-10 03:51:37
我通过使用koala提供的字段键解决了我的问题,它更高效,运行速度更快:
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
endhttps://stackoverflow.com/questions/11397716
复制相似问题