我一直在搜索 Google 和 SO,但找不到 com.apple.accounts 错误代码 8 的含义。我正在尝试使用 iOS 6 和 Facebook SDK。
我运行这个请求;
if (!_accountStore) _accountStore = [[ACAccountStore alloc] init];
ACAccountType *fbActType = [_accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSDictionary *options = [[NSDictionary alloc] initWithObjectsAndKeys:
(NSString *)ACFacebookAppIdKey, @"###############",
(NSString *)ACFacebookPermissionsKey, [NSArray arrayWithObject:@"email"],
nil];
[_accountStore requestAccessToAccountsWithType:fbActType options:options completion:^(BOOL granted, NSError *error) {
if (granted) {
NSLog(@"Success");
NSArray *accounts = [_accountStore accountsWithAccountType:fbActType];
_facebookAccount = [accounts lastObject];
} else {
NSLog(@"ERR: %@",error);
// Fail gracefully...
}
}
];
我收到此错误:
ERR: Error Domain=com.apple.accounts Code=8 "The operation couldn’t be completed. (com.apple.accounts error 8.)"
无论我做什么,都granted
不会返回 true。任何想法将不胜感激。
如果我绕过if(granted)
并调用此函数:
- (void)me{
NSLog(@"Home.m - (void)me");
NSURL *meurl = [NSURL URLWithString:@"https://graph.facebook.com/me"];
SLRequest *merequest = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodGET
URL:meurl
parameters:nil];
merequest.account = _facebookAccount;
[merequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSString *meDataString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(@"%@", meDataString);
}];
然后我看到 Facebook 返回的这个 JSON:
{"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}}
更新:因此,错误意味着“客户端的访问信息字典的值不正确或缺失”。但我不知道那是什么意思。