Hey everyone, I've been trying to get Twitpic to work successfully in uploading a picture through my iPhone app. This has worked fine in the past however now they've changed all their auth code.
This is what I've got, and for some reason is just giving me a failure:
oAuth = [[OAuth alloc] initWithConsumerKey:twitter_consumer_key andConsumerSecret:twitter_consumer_secret];
NSString *fakeurl = @"https://api.twitter.com/1/account/verify_credentials.json";
NSString *oauth_header = [oAuth oAuthHeaderForMethod:@"GET" andUrl:fakeurl andParams:nil];
NSLog(@"OAuth header : %@\n\n", oauth_header);
NSString *url = @"http://api.twitpic.com/2/upload.json";
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:url]];
request.delegate = self;
[request addRequestHeader:@"User-Agent" value:@"ASIHTTPRequest"];
request.requestMethod = @"GET";
[request addRequestHeader:@"X-Verify-Credentials-Authorization" value:oauth_header];
[request addRequestHeader:@"X-Auth-Service-Provider" value:@"https://api.twitter.com/1/account/verify_credentials.json"];
if (_imageData) {
NSLog(@"Pic not nil");
}
[request setData:_imageData forKey:@"media"];
[request setPostValue:@"" forKey:@"message"];
[request setPostValue:twitpic_api_key forKey:@"key"];
[request setDelegate:self];
[request setDidFinishSelector:@selector(requestDone:)];
[request setDidFailSelector:@selector(requestFailed:)];
[request start];