0

我想知道如何使用 facebook 令牌获取电子邮件和姓名?目前它为所有字段返回 null。我正在使用有效的未过期令牌。提前致谢!

例如:

facebook_token = 'MY ACCESS TOKEN' # params[:facebook_token]
@user = FbGraph::User.me(facebook_token)
render :json=> @user, :status=>200

回复

{
   "identifier":"me",
   "endpoint":"https://graph.facebook.com/me",
   "access_token":"MY ACCESS TOKEN",
   "raw_attributes":
       {
         "access_token":"MY ACCESS TOKEN"
       },
   "cached_collections":{},
   "name":null,
   "first_name":null,
   "middle_name":null,
   "last_name":null,
   "gender":null,
   "locale":null,
   "link":null,
   "username":null,
   "third_party_id":null,
   "timezone":null,
   "verified":null,
   "about":null,
   "bio":null,
   "email":null,
   "political":null,
   "quotes":null,
   "relationship_status":null,
   "relationship":null,
   "video_upload_limits":null,
   "website":null,
   "mobile_phone":null,
   "installed":null,
   "rsvp_status":null,
   "security_settings":null,
   "currency":null,
   "religion":null,
   "languages":[],
   "education":[],
   "interested_in":[],
   "favorite_teams":[],
   "work":[],
   "devices":[],
   "sports":[],
   "favorite_athletes":[],
   "inspirational_people":[]
 }
4

1 回答 1

2

利用@user = FbGraph::User.me(facebook_token).fetch

然后,您将使用以下方式获得电子邮件和名称。

user_email = @user.email
user_name = @user.name
于 2013-06-25T08:07:26.023 回答