ios - 无法在 ios 中使用带有自定义按钮的 api v2.4 登录 facebook

标签 ios objective-c facebook authentication facebook-graph-api-v2.4

我正在尝试使用 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/

相关文章:

objective-c - 循环遍历类似名称的控件

iOS Reachability SCNetworkReachabilitySetCallback 当从 wifi 切换到 anthor wifi 时不回调

facebook - 在Facebook iOS SDK中获取Facebook用户 friend 姓名列表的最有效方法是什么?

ios - Apple 的可下载/可执行代码限制如何与在 UIWebView 中使用 HTML5 和 Javascript 相符?

jquery - 在 iPhone 中使用 Jquery 的日期选择器

iphone - iOS 电子书应用程序创建者/制作者

c# - Facebook 分享按钮的不同 URL

ruby-on-rails - 考拉的 react 时间。 20秒等待响应

iOS/AVFoundation : Design pattern for asynch handlers when turning arrays of images into tracks and then into a single video?

ios - UIViewPropertyAnimator - 只是停止所有动画,而不是特定的动画?