How do I get the Facebook user Id from the Facebook object in the iOS SDK?

家住魔仙堡 提交于 2019-12-05 01:49:57

You will have to call /me to get the id. iOS access tokens are now encrypted and thus you won't be able to parse the user id from it. Also, server side tokens will all be encrypted with oauth 2.0 soon too.

There is an easy way to get this these days; assuming you already have a FBSession open, you could just do this:

[FBRequestConnection startForMeWithCompletionHandler:
  ^(FBRequestConnection *connection, id result, NSError *error)
  {
      NSLog(@"facebook result: %@", result);
  }];

You can just use this:

[[account valueForKey:@"properties"] valueForKey:@"uid"]

E-mail can be found with this:

[[account valueForKey:@"properties"] valueForKey:@"ACUIDisplayUsername"]

where account is ACAccount type of course

Can get it with [FBSession activeSession].accessTokenData.userID

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!