(facebook sdk)com.facebook.sdk.core错误8

时间:2018-03-21 03:01:11

标签: ios facebook facebook-graph-api error-handling

我使用FBSDKLoginButton登录FB SDK(这就是我创建它的方式):

    loginButton = [[FBSDKLoginButton alloc] init];
    loginButton.readPermissions = @[@"public_profile", @"email", @"user_friends"];
    loginButton.delegate = self;
    loginButton.alpha = 0;
    loginButton.center = CGPointMake(-100, -100);
    [self.view addSubview:loginButton];

然后我有一个像这样的委托方法,但它不断返回错误

  

无法完成操作。 (com.facebook.sdk.core错误8。)

此代码是否有任何错误会导致返回错误8?我的info.plist中的所有内容似乎都正确,因为我按照他们的官方教程进行了验证。

- (void)loginButton:(FBSDKLoginButton *)loginButton
didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result
              error:(NSError *)error {
    //User is authenticated now
    NSLog(@"fb authenticated");

    //Do strict locations first
    NSMutableDictionary* parameters = [NSMutableDictionary dictionary];
    [parameters setValue:@"country,country_code,location" forKey:@"fields"];
    FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                                  initWithGraphPath:@"me/locations"
                                  parameters:parameters
                                  HTTPMethod:@"GET"];
    [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
        if (!error) {
            NSDictionary *userData = (NSDictionary *)result;
            NSString *countryName = userData[@"location"][@"country"];
            NSString *countryCode = userData[@"location"][@"country_code"];
            NSLog(@"countryName: %@ countryCode: %@", countryName, countryCode);
        } else {
            NSLog(@"error1: %@", [error localizedDescription]);
        }
    }];
}

1 个答案:

答案 0 :(得分:0)

确保您的权限输入正确。

您是否从此处下载了Facebook iOS SDK:http://github.com/facebook/facebook-ios-sdk。它包含从iOS连接到Facebook所需的所有内容,以及有关如何使用旧API和新Graph API的示例代码。