2012-01-02 22 views
4

enter image description here我一直在使用經典的Ben Gottlieb Twitter開源項目來爲iPad創建twitter登錄。objective-c:iPad上的Twitter登錄錯誤:Whoa there

我的代碼來實例化引擎和顯示登錄控制器:

if (!_engine) { 
     _engine = [[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate:self]; 
     [_engine setConsumerKey:@"kConsumerKey"]; 
     [_engine setConsumerSecret:@"kConsumerSecret"]; 
    } 

    if (![_engine isAuthorized]){ 
     UIViewController *controller = [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine:_engine delegate:self]; 
     if (controller){ 
      if ([controller respondsToSelector:@selector(setModalPresentationStyle:)] == YES) { 
       controller.modalPresentationStyle = UIModalPresentationFormSheet; 
      } 
      [self presentModalViewController:controller animated:YES]; 
      return; 
     } 

    } 

另外,我設置URL的SA_OAuthTwitterEngine到https:

self.requestTokenURL = [NSURL URLWithString: @"https://twitter.com/oauth/request_token"]; 
self.accessTokenURL = [NSURL URLWithString: @"https://twitter.com/oauth/access_token"]; 
self.authorizeURL = [NSURL URLWithString: @"https://twitter.com/oauth/authorize"]; 

和我MGTwitterEngine.m TWITTER_DOMAIN已更改爲:

#define TWITTER_DOMAIN   @"api.twitter.com/1" 

在代碼中運行此代碼iPhone和iPad的模擬器就像一個魅力。 但是,每當我一個iPad設備上測試此代碼,我拋出這個錯誤:

Whoa there! The request token for this page is invalid. It may have already been used, or expired because it is too old. Please go back to the site or application that sent you here and try again; it was probably just a mistake

(截圖附後)。

如何得到標準的登錄屏幕出現任何建議,將不勝感激

回答

1

我碰到了同樣的問題。會發生什麼是請求沒有得到請求令牌。你可以明確地說:

SA_OAuthTwitterEngine *myEngine; 
[myEngine requestRequestToken]; 

希望這有助於!

+0

傑夫凱利你能告訴我應該在哪裏添加這行代碼[myEngine requestRequestToken]; – Gypsa 2012-02-22 11:35:04

+0

將其添加到創建引擎的位置。 – 2012-02-22 19:30:14

+0

我試圖添加我創建引擎的位置,但它不起作用。 – Gypsa 2012-02-23 06:25:51

2

我有同樣的問題,並試圖傑夫的方式。它也沒有工作。由於某些未知原因,請檢查您的時間設置並設置爲自動設置時間。這對我有效。

+0

完美的男人,是的,這是我的情況,如果你改變了你的iPhone的時間,然後請求令牌不起作用,即使我曾試圖在twitter等創建新的令牌。 – UMAR 2012-09-24 16:25:14