【发布时间】:2018-08-30 01:07:20
【问题描述】:
我正在使用 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]);
}
}];
}
【问题讨论】:
标签: ios facebook facebook-graph-api error-handling