2012-01-19 22 views
0

私のアプリケーションは、1か月前にtwitterにデータ(画像とテキスト)を投稿することができます。しかし今、Twitterにデータを投稿することはできません。なぜ...、どう?このメッセージではアプリケーションからTwitterにデータを投稿できませんか?

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

に従ってください、私は確認できない。 1がすでに使用されて:それは、このエラーだとき? 2.期限が切れたため期限切れ:トークンの有効期限が切れましたか?期限切れの再オープン方法 =>このエラーの解決策は何ですか?ありがとう!

+1

MGTwitterEngine –

+1

私は解決策http://www.musicalgeometry.com/?p=1537で見つけました。おかげで –

答えて

0

あなたがios 5で作業している場合、このコードの助けを借りてイメージとテキストを送信するので、次のコードが役立ちます。すべての最初の

は、フレームワーク「twitter.framework」

NSString *var = txtTwitter.text; 
    NSString *str = [[NSUserDefaults standardUserDefaults]valueForKey:@"INDEX"]; 


    ACAccountStore *accountStore = [[ACAccountStore alloc] init]; 

    // Create an account type that ensures Twitter accounts are retrieved. 
    ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; 

    // Request access from the user to use their Twitter accounts. 
    [accountStore requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error) { 
     if(granted) { 
      // Get the list of Twitter accounts. 
      NSArray *accountsArray = [accountStore accountsWithAccountType:accountType]; 


      if ([accountsArray count] > 0) { 

       ACAccount *twitterAccount = [accountsArray objectAtIndex:0]; 

       TWRequest *postRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:@"https://upload.twitter.com/1/statuses/update_with_media.json"] parameters:nil requestMethod:TWRequestMethodPOST]; 

       //add text 
       [postRequest addMultiPartData:[var dataUsingEncoding:NSUTF8StringEncoding] withName:@"status" type:@"multipart/form-data"]; 

       UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"00%@.jpg",str]]; 

       //add image 
       [postRequest addMultiPartData:UIImagePNGRepresentation(image) withName:@"media" type:@"multipart/form-data"]; 

       // Set the account used to post the tweet. 
       [postRequest setAccount:twitterAccount]; 

       [postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { 
        NSString *output = [NSString stringWithFormat:@"HTTP response status: %i", [urlResponse statusCode]]; 
        NSLog(@"Twitter msg %@",output); 
        //      [self performSelectorOnMainThread:@selector(displayText:) withObject:output waitUntilDone:NO]; 
       }]; 
      } 
     } 
    }]; 
+0

ありがとう!私のアプリケーションはiOS 4,5で起動しているので、私はMGTwitterEngineを使う必要があります –

0

リクエストトークンが期限切れの持っているため、エラーがあるかもしれないを追加します。 アクセストークンを再生成する必要があります。

https://dev.twitter.com/にアクセスし、アクセストークンを再作成します。

+0

ありがとう!しかし、この解決策は、私は再びこのパラメータはアプリのコードに含まれているため、私のアプリケーションをコンパイルする必要があります。 –

+0

はい、あなたのアプリをもう一度コンパイルする必要があります。これらのトークンは非常に機密であるため、ある期間、トゥイーターはトークンを失効します。 – vikiiii

+0

ある期間、twitterがトークンを期限切れにした場合、アップル市場用のbussinessアプリケーションを開発する方法は? Twitterトークンの有効期限はどのくらいですか? –

関連する問題