首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用考拉Ruby gem从Facebook上检索好友education_history

使用考拉Ruby gem从Facebook上检索好友education_history
EN

Stack Overflow用户
提问于 2012-07-09 23:00:07
回答 1查看 823关注 0票数 0

我想检索一个用户的朋友education_history,我正在使用考拉宝石和rubyonrails。

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

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

代码语言:javascript
复制
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

有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-07-10 03:51:37

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

代码语言:javascript
复制
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
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11397716

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档