Hi I am using following code to post image to Twitter using twitpic.
But I am getting server response code 401 for the same.

    ASIFormDataRequest *req = [[ASIFormDataRequest alloc] initWithURL:
[NSURL URLWithString:@"http://api.twitpic.com/2/upload.json";]];

    [req addRequestHeader:@"X-Auth-Service-Provider" value:@"https://
api.twitter.com/1/account/verify_credentials.json"];
    [req addRequestHeader:@"X-Verify-Credentials-Authorization"
                    value:[oAuth oAuthHeaderForMethod:@"GET"
                                               andUrl:@"https://
api.twitter.com/1/account/verify_credentials.json"
                                            andParams:nil]];



    [req setData:UIImageJPEGRepresentation(imageView.image, 0.8)
forKey:@"media"];

    // Define this somewhere or replace with your own key inline right
here.
    [req setPostValue:TWITPIC_API_KEY1 forKey:@"key"];

    // TwitPic API doc says that message is mandatory, but looks like
    // it's actually optional in practice as of July 2010. You may or
may not send it, both work.
    // [req setPostValue:@"hmm what" forKey:@"message"];

    [req startSynchronous];



    NSLog(@"Got HTTP status code from TwitPic: %d", [req
responseStatusCode]);
    NSDictionary *twitpicResponse = [[req responseString] JSONValue];
    textView.text = [NSString stringWithFormat:@"Posted image URL:
%@", [twitpicResponse valueForKey:@"url"]];
    [req release];

Please help me to identify where  I am going wrong.

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk

Reply via email to