从iOS 5访问twitter时OAuth访问令牌失败



我使用MGTwitterEngine"将twitter整合到我的应用程序中。它可以很好地工作到iOS 4.2。当我尝试从任何iOS 5设备访问twitter时,我遇到了一个身份验证令牌问题。

This page is no longer valid. It looks like someone already used the token information you provided. Please return to the site that sent you to this page and try again ... it was probably an honest mistake

在谷歌上搜索了很多之后,我找到了一些建议,但是他们并没有解决我的问题。尝试使用https代替http .

尝试替换

请求令牌URL

https://api.twitter.com/oauth/request_token

授权URL

https://api.twitter.com/oauth/authorize

访问令牌URL

https://api.twitter.com/oauth/access_token

我解决了这个检测iOS版本的问题,以便在iOS 4.3和更早的版本中使用MGTwitterEngine,在iOS5中使用TWRequest和Twitter API。

NSString *requiredVersion = @"5.";
NSRange aRange = [[[UIDevice currentDevice] systemVersion] rangeOfString:requiredVersion];

if (aRange.location == NSNotFound )
{
      //MGTwitterEngine here
} else {
      //Twitter API here
}

这对我有用,我希望它对你也有用。

我尝试了上述所有解决方案,但这些都不能解决这个问题。最后我这样做了:

requestRequestToken set new request token

 [engine requestRequestToken];// added this to remove the old request token because old request token will not work with new authentication request 
 UIViewController *controller = [[SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine:engine delegate:self] retain];  
 [delegate presentModalViewController: controller animated: YES];

注意:它增加了加载web视图的时间。

我想这会有帮助的。

最新更新