如何通过koala gem检索fb的用户关系状态?

时间:2013-01-28 13:44:48

标签: ruby-on-rails facebook koala

我安装了宝石koalaomniauth。 在我的user模型中

class User < ActiveRecord::Base
def self.from_omniauth(auth)
where(auth.slice(:provider, :uid)).first_or_initialize.tap do |user|
  user.provider = auth.provider
  user.uid = auth.uid
  user.name = auth.info.name
  user.image = auth.info.image
  user.oauth_token = auth.credentials.token
  user.oauth_expires_at = Time.at(auth.credentials.expires_at)
  user.save!
end
end

def facebook
  @facebook ||= Koala::Facebook::API.new(oauth_token)
end

end

我获得了facebook的许可,但我仍然无法获得关系状态?

1 个答案:

答案 0 :(得分:2)

试试这个

@facebook.get_object('me',:fields=>"name,gender,relationship_status")