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
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
You must use a "twitter-picture-provider" like TwitPic, TweetPhoto or yfrog. They usually provide their own APIs as far as I know.
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.
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.