gpt4 book ai didi

facebook-graph-api - Facebook访问 token 已过期-iOS 6社交框架

转载 作者:行者123 更新时间:2023-12-03 22:05:50 24 4
gpt4 key购买 nike

我正在制作一个基于iOS6社交框架的应用程序...它工作正常,但是几个月后出现了一个奇怪的错误。

我将导入的JSON Facebook数据导入NSDictionary的NSLog是:

profiledictionary: {
error = {
code = 190;
"error_subcode" = 463;
message = "Error validating access token: Session has expired at unix time 1365610034. The current unix time is 1366032783.";
type = OAuthException;

似乎我的访问 token 已过期,但是iOS6社交框架不应该自动处理吗?

关于如何解决它以及避免将来出现此类问题的任何想法,这样我就可以安全地发布真实的应用程序了吗?

最佳答案

终于知道了...有必要检查NSDictionary是否有一个名为“错误”的对象(在这种情况下,有关 token 的Facebook错误已过期),如果是,则调用一种方法来续订ACAccount:

if([self.profileDictionary objectForKey:@"error"]!=nil)
{
[self attemptRenewCredentials];
}

-(void)attemptRenewCredentials{
[self.accountStore renewCredentialsForAccount:(ACAccount *)self.facebookAccount completion:^(ACAccountCredentialRenewResult renewResult, NSError *error){
if(!error)
{
switch (renewResult) {
case ACAccountCredentialRenewResultRenewed:
NSLog(@"Good to go");
[self getFacebookAccount];
break;
case ACAccountCredentialRenewResultRejected:
NSLog(@"User declined permission");
break;
case ACAccountCredentialRenewResultFailed:
NSLog(@"non-user-initiated cancel, you may attempt to retry");
break;
default:
break;
}

}
else{
//handle error
NSLog(@"error from renew credentials%@",error);
}
}];
}

关于facebook-graph-api - Facebook访问 token 已过期-iOS 6社交框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16024658/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com