TWRequest performRequestWithHandler no error, but nothing happens

I'm trying to share using the Twitter platform on iOS 5. The user will choose which account to use, so the application will share using the selected account.

But whem bandwidth goes through to performRequestWithHandler nothing happens error return null

My code is:

 for (int i = 0; i < [_accountsArray count]; i++) { //searching for a selected account if ([[[_accountsArray objectAtIndex:i] username] isEqualToString:[self getUserName]]) { actualUser = [_accountsArray objectAtIndex:i]; TWRequest *sendTweet = [[TWRequest alloc] initWithURL:[NSURL URLWithString:@"https://upload.twitter.com/1/statuses/update_with_media.json"] parameters:nil requestMethod:TWRequestMethodPOST]; [sendTweet addMultiPartData:[text dataUsingEncoding:NSUTF8StringEncoding] withName:@"status" type:@"multipart/form-data"]; ACAccountStore *account = [[ACAccountStore alloc] init]; [sendTweet setAccount:[account.accounts objectAtIndex:i]]; NSLog(@"%@",sendTweet.account); [sendTweet performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { NSLog(@"responseData: %@\n", responseData); NSLog(@"urlResponse: %@\n", urlResponse); NSLog(@"error: %@",error); }]; } } 

Can anybody help me?

thanks

+4
source share
1 answer

Sending tweets on iOS is very simple. Last night, I updated the application so that I no longer use the old method and instead use the new SLComposeViewController method. Below is a snippet of code that I have in the application that allows the user to send a tweet with an attached image. Basically, the same code can be used to post to facebook. Try using this code instead. It should also let the user choose which account they are sending the tweet from (I also think that this default โ€œsendโ€ setting is similar to the phone settings somewhere).

 if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) { SLComposeViewController *mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; [mySLComposerSheet setInitialText:@"Sample Tweet Text"]; //Add the image the user is working with [mySLComposerSheet addImage:self.workingImage]; //Add a URL if desired //[mySLComposerSheet addURL:[NSURL URLWithString:@"http://google.com"]]; //Pop up the post to the user so they can edit and submit [self presentViewController:mySLComposerSheet animated:YES completion:nil]; //Handle the event [mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) { switch (result) { case SLComposeViewControllerResultCancelled: NSLog(@"Tweet Canceled"); case SLComposeViewControllerResultDone: NSLog(@"Tweet Done"); break; default: break; } }]; } else { //Can't send tweets, show error NSLog(@"User doesn't have twitter setup"); } 
+1
source

Source: https://habr.com/ru/post/1434709/


All Articles