1

新しい iOS 6 アカウント フレームワークを使用して、Facebook から適切に情報を要求する方法を見つけました。私の問題は、資格情報を更新した後でも、Facebook からまだアクセスできないと言われることです。最後の (有効な) トークンが期限切れになり、新しいトークンを取得できなくなったと思います。すべてのアカウント (tw + fb) が正しく設定されている必要があります。また、renewResultACAccountCredentialRenewResultFailedであり、何でもかまいません...

これが私のコードです:

- (void)performSocialRequest:(SLRequest *)request completion:(void (^)(NSDictionary *responseDict))completion{
    __block NSDictionary *accountInfo;
    [request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
        if ([request.account.accountType.identifier isEqualToString:ACAccountTypeIdentifierTwitter]) {
            accountInfo = [[NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error]lastObject];
            completion(accountInfo);
        } else {
            accountInfo = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
            if ([accountInfo objectForKey:@"error"]) {
                [self.accountStore renewCredentialsForAccount:request.account completion:^(ACAccountCredentialRenewResult renewResult, NSError *error) {
                    if (renewResult == ACAccountCredentialRenewResultRenewed) {
                        NSLog(@"renewal succesful");
                        [request performRequestWithHandler:^(NSData *responseData2, NSHTTPURLResponse *urlResponse, NSError *error) {
                            completion([NSJSONSerialization JSONObjectWithData:responseData2 options:kNilOptions error:&error]);
                        }];
                    } else if (renewResult == ACAccountCredentialRenewResultRejected) {
                        NSLog(@"rejected");
                        completion(accountInfo);
                    } else if (renewResult == ACAccountCredentialRenewResultFailed){
                        NSLog(@"unknown (error: %@)", error);
                        completion(accountInfo);
                    }
                }];
            } else {
                completion(accountInfo);
            }
        }
    }];
}

Facebook サーバーから得られる回答は常に同じです。

{
error =     {
    code = 2500;
    message = "An active access token must be used to query information about the current user.";
    type = OAuthException;
};
}

皆さんにいくつかのアイデアがあることを願っています、事前に感謝します...

ダリオ

4

0 に答える 0