![](/img/trans.png)
[英]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.