Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9219187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:03:17+00:00 2026-06-18T03:03:17+00:00

I am trying to upload a image to the twitter api. I am using

  • 0

I am trying to upload a image to the twitter api. I am using PlainOAuth. Here’s what I have:

oauth_token = accessToken;
oauth_token_secret = accessTokenSecret;
OAuth *oAuth = [[OAuth alloc] initWithConsumerKey:***** andConsumerSecret:****];
oAuth.oauth_token = accessToken;
oAuth.oauth_token_secret = accessTokenSecret;
oAuth.oauth_token_authorized = YES;
[oAuth release];

NSString *url = @"https://api.twitter.com/1.1/statuses/update_with_media.json";
NSArray *params = [NSArray arrayWithObjects:
                   [NSString stringWithFormat:@"%@=%@", @"status", [tweetStatus encodedURLParameterString]],
                   imageData, @"media[]",
                   nil];
NSDictionary *paramsDict = [NSDictionary dictionaryWithObjectsAndKeys:
                            imageData, @"media[]",
                            tweetStatus, @"status",
                            [accessToken stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding], @"oauth_token",
                            nil];

NSString *oauth_header = [super oAuthHeaderForMethod:@"POST" andUrl:url andParams:paramsDict andTokenSecret:accessTokenSecret];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:10.0f];
[request setHTTPMethod:@"POST"];

NSMutableData *body = [[NSMutableData alloc] initWithData:[[params componentsJoinedByString:@"&"] dataUsingEncoding:NSUTF8StringEncoding]];
NSString *boundary = @"---------------------------14737809831466499882746641449";
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
[request addValue:contentType forHTTPHeaderField:@"Content-Type"];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[@"Content-Disposition: form-data; name=\"media[]\"; filename=\"media.jpg\"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[@"Content-Type: binary\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[NSData dataWithData:imageData]];
[request setHTTPBody:body];

[request addValue:oauth_header forHTTPHeaderField:@"Authorization"];
NSHTTPURLResponse *response;
NSError *error = nil;
NSString *responseString = [[[NSString alloc] initWithData:[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error] encoding:NSUTF8StringEncoding] autorelease];

responseString is outputting blank. So I’m guessing there is a 404 error? if I remove the media[] info from either of my paramaters array, I get a oAuth error.

Please help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:03:18+00:00Added an answer on June 18, 2026 at 3:03 am
    TWTweetComposeViewController *twitterViewController = [[TWTweetComposeViewController alloc] init];
    
    NSString *twitterText = [NSString stringWithFormat:@"%@%@%@", kBookingShareTwitterText, kBookingShareFlightURL, bookingId];
    [twitterViewController setInitialText:twitterText];
    [twitterViewController addImage:[UIImage imageNamed:@"logo.png"]];
    [self presentModalViewController:twitterViewController animated:YES];
    
    [twitterViewController setCompletionHandler:^(TWTweetComposeViewControllerResult result) {
    
        switch (result) {
    
            case SLComposeViewControllerResultCancelled:
                [self dismissModalViewControllerAnimated:YES];
                break;
    
            case SLComposeViewControllerResultDone:
                [self updateBookingWithFriendsInvitationFlag];
                break;
    
            default:
                break;
        }
    
    
    }];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to upload an image using CodeIgniter's File Upload class. The
I'm trying to post images to Twitter using the Oauth module. Here is what
i am trying to upload an image from a jsp page using servlet. but
I have this Form I am trying to upload my image but every time
Im struggling here for a lot, Im trying to upload an image from iphone
I'm trying to upload an image to dropbox. I'm using the latest version of
I am trying to upload an image to server using iphone . I haven't
I am trying to post an image to twitter using update_with_media.json. The following is
I am trying to upload a photo using the API and am having an
So far I have been trying to update the twitter profile bg image thr

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.