Facebook续订凭证后请求不起作用(帐户框架)

时间:2013-01-22 15:33:45

标签: iphone facebook ios6 acaccount

我刚刚想出如何使用新的iOS 6帐户框架正确地从Facebook请求信息。我现在的问题是,在我更新凭据后,Facebook仍然告诉我,我没有访问权限。我想我的最后一个(工作)令牌已过期,现在我无法获得新的令牌。应正确设置所有帐户(tw + fb)。 renewResult 也是 ACAccountCredentialRenewResultFailed ,它可以是任何东西......

这是我的代码:

- (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;
};
}

希望你们有一些想法,提前谢谢......

的Dario

0 个答案:

没有答案