0

当我的应用程序尝试邀请用户朋友列表中的人时,它会检查活动会话的权限。如果没有找到这两个权限,它会调用 reauthorizeWithPublishPermissions。

有问题的代码如下:

if ([FBSession.activeSession.permissions indexOfObject:@"publish_stream"] == NSNotFound || [FBSession.activeSession.permissions indexOfObject:@"user_photos"] == NSNotFound ) {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

    [defaults setBool:YES forKey:@"FacebookLogin"];
    [FBSession.activeSession reauthorizeWithPublishPermissions:[NSArray arrayWithObjects:@"publish_stream",@"user_photos", nil]
           defaultAudience:FBSessionDefaultAudienceFriends
         completionHandler:^(FBSession *session, NSError *error)
                            {
                                if (error)
                                {
                                    UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Can not get permission"
                                                                                    message:error.localizedFailureReason
                                                                                   delegate:self
                                                                          cancelButtonTitle:@"Ok"
                                                                          otherButtonTitles:nil];
                                    [alert show];
                                    [alert release];
                                    [defaults setBool:YES forKey:@"FacebookLogin"];
                                }
                                else {
                                    if([[SocialNetworkingData getInstance] getFBDisplayType] == 0)
                                    {
                                        [self postFeedWithPermission:friendList];
                                    }
                                    else if ([[SocialNetworkingData getInstance] getFBDisplayType] == 1)
                                    {
                                        [self postPhotoWithPermission:friendList];
                                    }
                                    else if([[SocialNetworkingData getInstance] getFBDisplayType] == 2){
                                        [self postFeedDialog:friendList];
                                    }

                                }
                            }];
}

else
{
    if([[SocialNetworkingData getInstance] getFBDisplayType] == 0) {
        [self postFeedWithPermission:friendList];
    }
    else if ([[SocialNetworkingData getInstance] getFBDisplayType] == 1) {
        [self postPhotoWithPermission:friendList];
    }
    else if([[SocialNetworkingData getInstance] getFBDisplayType] == 2){
        [self postFeedDialog:friendList];
    }
}

无论如何,完成处理程序都会收到错误 2。

4

1 回答 1

0

检查您的应用在设置> Facebook 中是否已获得授权 ^_^

于 2013-06-12T17:33:05.087 回答