我正在尝试使用 api v2.4 并使用自定义按钮登录,但我没有成功。我能够获得 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);
}
}];
}
}
关于ios - 无法在 ios 中使用带有自定义按钮的 api v2.4 登录 facebook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32175168/