tags:

views:

83

answers:

4

Hello All,

I want to upload image on Twitter.

please any one help me how we upload image on Twitter. Please explain or provide code.

Thanks Rockydilse

+1  A: 

Use Twitpic

codersarepeople
+1  A: 

You must use a "twitter-picture-provider" like TwitPic, TweetPhoto or yfrog. They usually provide their own APIs as far as I know.

Arve Systad
Thanks can you please explain how to upload image using TwitPic.Or send me code for using it.
Rockydilse
Not much better than the documentation (http://dev.twitpic.com/) itself. If you've got no experience in using such APIs, you should google it a bit. I have never developed for the iPhone (or the TwitPic API for that matter), so I cannot give any concrete code. Some googling, the documentation and some work is pretty much what's needed.
Arve Systad
A: 

Twitter does not host image uploads at the moment. You have to use a third-party service. Yfrog and Twitpic are the two most popular on Twitter.

Brock Batsell
Thanks can you send sample code twit pic.
Rockydilse
Can you explain how we used ASIFormDataRequest class.How we get code of ASIFormDataRequest class.
Rockydilse
+2  A: 

The following is to utilize Twitpic.

As said by others you have to start by looking at the API to understand the requests.

You can use Oliver Drobnik's Tutorial : Uploading UIImages to TwitPic which does it from scratch using NSMutableURLRequest

or you can use the asi-http-request which is a CFNetwork wrapper for HTTP requests

NSData *imageData = UIImagePNGRepresentation(imageToPost);
NSURL *twitpicURL = [NSURL URLWithString:@"http://twitpic.com/api/uploadAndPost"];

ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:twitpicURL] autorelease];

[request setData:imageData forKey:@"media"];
[request setPostValue:@"myUsername" forKey:@"username"];
[request setPostValue:@"myPassword" forKey:@"password"];
[request setPostValue:@"myMessage" forKey:@"message"];

[request setDelegate:self];
[request setDidFinishSelector:@selector(requestDone:)];
[request setDidFailSelector:@selector(requestFailed:)];

[request start];

You should look at the first.. first that way you understand what is happening.

phwd