1

我刚刚弄清楚如何使用新的 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;
};
}

希望各位大神给点意见,先谢谢了。。。

达里奥

4

0 回答 0