我正在尝试使用api v2.4使用facebook登录并使用自定义按钮进行登录,但我没有成功。我能够获得 facebook id,但其余信息为空。我已经完成了与早期版本的 api 相同的操作,它运行良好。谁能告诉我现在该怎么办?
您的帮助将不胜感激。
我正在尝试使用api v2.4使用facebook登录并使用自定义按钮进行登录,但我没有成功。我能够获得 facebook id,但其余信息为空。我已经完成了与早期版本的 api 相同的操作,它运行良好。谁能告诉我现在该怎么办?
您的帮助将不胜感激。
你尝试这种方式来获取信息。
facebook SDK 4.x 获取任何信息,然后像这样传递参数请求字段
parameters:@{@"fields": @"id, name, link, first_name, last_name, picture.type(large), email, birthday, bio ,location ,friends ,hometown , friendlists"}
- (IBAction)btnFacebookPressed:(id)sender {
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:@[@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
{
if (error)
{
// Process error
}
else if (result.isCancelled)
{
// Handle cancellations
}
else
{
if ([result.grantedPermissions containsObject:@"email"])
{
NSLog(@"result is:%@",result);
[self fetchUserInfo];
}
}
}];
}
-(void)fetchUserInfo
{
if ([FBSDKAccessToken currentAccessToken])
{
NSLog(@"Token is available : %@",[[FBSDKAccessToken currentAccessToken]tokenString]);
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"id, name, link, first_name, last_name, picture.type(large), email, birthday, bio ,location ,friends ,hometown , friendlists"}]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error)
{
NSLog(@"resultis:%@",result);
}
else
{
NSLog(@"Error %@",error);
}
}];
}
}