简体   繁体   English

无法在iOS中使用具有自定义按钮的api v2.4登录到Facebook

[英]Not able to login with facebook using api v2.4 with custom button in ios

I am trying to log in with facebook using api v2.4 and using custom button for login but I am not getting success. 我正在尝试使用api v2.4和使用自定义按钮登录到Facebook ,但是我没有成功。 I am able to get facebook id but rest info is coming null. 我可以获取Facebook ID,但其余信息为空。 I have done the same as in the earlier version of api it is working well. 我做的和早期版本的api一样,效果很好。 Can anyone tell me what should I do now? 谁能告诉我现在该怎么办?

Your help would be appreciated. 您的帮助将不胜感激。

You try this way to get information. 您尝试通过这种方式获取信息。

And facebook SDK 4.x get any information then pass parameter request fields like this way 和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);
             }
         }];

    }

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM