我正在使用Facebook帐户制作应用登录功能。我通过运行此命令获得了Facebook tokenkey
:appDelegate.session.accessTokenData.accessToken
。然后我像这样username
和user_ID
:
FBRequest *request = [FBRequest requestForMe];
[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (error == nil) {
// result is a dictionary with the user's Facebook data
NSDictionary *userData = (NSDictionary *)result;
NSString *facebookID = userData[@"id"];
NSLog(@"facebookID = %@",facebookID);
或
if (FBSession.activeSession.isOpen) {
[[FBRequest requestForMe] startWithCompletionHandler:
^(FBRequestConnection *connection,
NSDictionary<FBGraphUser> *user,
NSError *error) {
if (!error) {
self.userNameLabel.text = user.name;
self.userProfileImage.profileID = user.id;
}
}];
}
结果是一样的,当我调试时它总是在if(!error)
中跳起来。
这个错误来自哪里?