[英]Fetching facebook friends using koala gem is not returning all the friends
[英]Retrieve friends education_history from Facebook using koala Ruby gem
我想找一个用户朋友education_history,我正在使用考拉宝石和红宝石。
我已经在omitaluth的initalizer文件中添加了获取用户朋友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
有任何想法吗?
我通过使用考拉提供的字段键解决了我的问题,它更有效,工作速度更快:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.