我需要在 Facebook 时间线上发布状态。我的代码包含 2 个请求。第一个用于验证电子邮件权限,第二个用于验证发布权限。我通过权限“电子邮件”请求获得成功响应,但在第二种情况下出现错误“发布权限错误:操作无法完成。(com.apple.accounts 错误 8。)”。你有什么想法可能是错误的吗?感谢帮助。
- (void)facebookStatus:(NSString *)identifier {
ACAccountStore *accountStore = [[ACAccountStore alloc]init];
ACAccountType *FBaccountType= [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSString *key = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"FacebookAppID"];
NSDictionary *options = @{
ACFacebookAppIdKey : key,
ACFacebookPermissionsKey : @[@"email"]
};
[accountStore requestAccessToAccountsWithType:FBaccountType options:options completion:^(BOOL granted, NSError *error) {
if (granted) {
NSArray *accounts = [accountStore accountsWithAccountType:FBaccountType];
if ([accounts count] > 0) {
ACAccountStore *accountStore = [[ACAccountStore alloc]init];
ACAccountType *FBaccountType= [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSString *key = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"FacebookAppID"];
NSDictionary *options = @{
ACFacebookAppIdKey : key,
ACFacebookPermissionsKey : @[@"publish_stream"]
};
[accountStore requestAccessToAccountsWithType:FBaccountType options:options completion:^(BOOL granted2, NSError *error) {
if (granted2) {
NSLog(@"Publish")
;
}
else {
NSLog(@"Publish permission error: %@", [error localizedDescription]);
//_publishPermissionsGranted = NO;
}
}];
}
}
else NSLog(@"Nope");
if (error) {
if (error.code == 6) {
NSLog(@"FB Account doesn't exist");
}
NSLog(@"Error: %@", error.localizedDescription);
}
}];
}