0

Facebook を iOS アプリと統合しようとしていますが、問題が発生しています。

このコードを最初に実行したときは完全に機能しましたが、Facebook キャッシュ内の何かがこのエラーを引き起こしているようです:「現在のユーザーに関する情報を照会するには、アクティブなアクセス トークンを使用する必要があります。」

これらの 2 つの関数を使用して、写真をアップロードしようとしています。

+(BOOL)logInAndPostImage:(UIImage*)image andMessage:(NSString*)message {

    NSArray *permissions = [NSArray arrayWithObjects:@"publish_stream", nil];
    [FBSession.activeSession closeAndClearTokenInformation];
    return [FBSession  openActiveSessionWithPublishPermissions:permissions
                                              defaultAudience:FBSessionDefaultAudienceOnlyMe
                                                 allowLoginUI:YES
                                            completionHandler:
            ^(FBSession *session, FBSessionState state, NSError *error) {
                [self sessionStateChanged:session
                                    state:state
                                    error:error];
                if(error) {
                    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Problem connecting with Facebook" delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil];
                    [alert show];
                } else {
                    [self postImage:image andMessage:message];
                }
            }];
}

+(void)postImage:(UIImage*)image andMessage:(NSString*)message
{

    NSLog(@" Access Token Description: %@",[[FBSession activeSession] accessToken].description);

    [FBRequestConnection startForUploadPhoto:image completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
        if (!error) {
            [[[UIAlertView alloc] initWithTitle:@"Result"
                                        message:@"Your update has been posted to Facebook!"
                                       delegate:self
                              cancelButtonTitle:@"Sweet!"
                              otherButtonTitles:nil] show];
        } else {
            [[[UIAlertView alloc] initWithTitle:@"Error"
                                        message:@"Yikes! Facebook had an error.  Please try again!"
                                       delegate:nil
                              cancelButtonTitle:@"Ok"
                              otherButtonTitles:nil] show];
            NSLog(@"%@", error);
        }

    }];
}

アクティブなトークンの説明の説明を照会すると、実際には null です。whileFBSession openActiveSessionWithPublishPermissions:defaultAudience:allowLoginUI:completionHandler:がエラーを返さないと思いますが、トークンを生成していませんか?

このエラーをさらにデバッグする方法について何か提案はありますか? Facebook 開発者ページで概説されているすべての追加設定に従いました。

4

1 に答える 1