【发布时间】:2013-09-04 21:40:49
【问题描述】:
我正在使用以下代码来处理我的应用程序中的 twitter 集成。
- (IBAction)signInWithTwitter:(id)sender {
NSURL *requestURL = [NSURL URLWithString:@"https://api.twitter.com/oauth/request_token"];
NSURL *accessURL = [NSURL URLWithString:@"https://api.twitter.com/oauth/access_token"];
NSURL *authorizeURL = [NSURL URLWithString:@"https://api.twitter.com/oauth/authorize"];
NSString *scope = @"http://api.twitter.com/";
GTMOAuthAuthentication *auth = [self authForTwitter];
[auth setCallback:@"http://www.noop.com/OAuthCallback"];
GTMOAuthViewControllerTouch *viewController;
viewController = [[GTMOAuthViewControllerTouch alloc] initWithScope:scope
language:nil
requestTokenURL:requestURL
authorizeTokenURL:authorizeURL
accessTokenURL:accessURL
authentication:auth
appServiceName:@"CK12: Twitter"
delegate:self
finishedSelector:@selector(viewController:finishedWithAuth:error:)];
}
- (GTMOAuthAuthentication *)authForTwitter {
GTMOAuthAuthentication *auth = [[GTMOAuthAuthentication alloc] initWithSignatureMethod:kGTMOAuthSignatureMethodHMAC_SHA1
consumerKey:TWITTER_CONSUMER_KEY
privateKey:TWITTER_CONSUMER_SECRET];
[auth setServiceProvider:@"Twitter"];
return auth;
}
我的问题是,如果我要更改设备时间,即延迟 1 小时,那么我会收到以下错误:
Error Domain=com.google.HTTPStatus Code=401 and error message is : failed to validate oauth signature and token .
那么任何人都可以建议如何解决这个问题。如果系统时间是错误的,那么我也想让它工作。
【问题讨论】:
-
您检查过您的应用程序密钥和应用程序密钥
-
如果系统时间正确,那么这工作正常。 . .所以应用密钥和应用密钥是正确的。
-
twitter 服务器检查你的请求的时间戳......所以你必须正确发送当前时间,我认为没有其他选择。
-
@IslamAhmed 我们可以获取推特服务器时间并根据推特服务器更改代码以使请求的时间戳正确
-
不可以,但是你可以在网上搜索一个时间服务的api并联系它来获取格林威治标准时间的当前时间。
标签: ios oauth twitter-oauth