Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have found and used so many great answers on this site, Thanks everyone, thought it's about time to give back :) Elaborating on Noah's answer, this is the final code that worked for me to get an image and text on a tweet using TWRequest...</p> <pre><code> TWRequest *postRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:@"https://upload.twitter.com/1/statuses/update_with_media.json"] parameters:nil requestMethod:TWRequestMethodPOST]; UIImage * image = [UIImage imageNamed:@"myImage.png"]; //add text [postRequest addMultiPartData:[@"I just found the secret level!" dataUsingEncoding:NSUTF8StringEncoding] withName:@"status" type:@"multipart/form-data"]; //add image [postRequest addMultiPartData:UIImagePNGRepresentation(image) withName:@"media" type:@"multipart/form-data"]; // Set the account used to post the tweet. [postRequest setAccount:twitterAccount]; // Perform the request created above and create a handler block to handle the response. [postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { NSString *output = [NSString stringWithFormat:@"HTTP response status: %i", [urlResponse statusCode]]; [self performSelectorOnMainThread:@selector(displayText:) withObject:output waitUntilDone:NO]; }]; </code></pre> <p>I found using TWRequest to be best solution for my scenario as I didn't want the user to be able to edit the post before tweeting (which was the issue with using TWTweetComposeViewController)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload