views:

1287

answers:

6

This is a weird one...

With the help of people here, I've got my iPhone app posting to TwitPic successfully - and when I first got it working, I could see an XML result being returned too...

But for some reason over the past two days, the API call seems to succeed - the pic appears on TwitPic - but... the response seems to be empty...

Anyone have any ideas? Seen anything similar? The code I use to invoke the API call is:

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

[request setData:twitpicImage forKey:@"media"];
[request setPostValue:username forKey:@"username"];
[request setPostValue:password forKey:@"password"];

// Initiate the WebService request
[request start];

// Need to find out how I can access the result from this call...

/* Result structure should be:

 <?xml version="1.0" encoding="UTF-8"?>
 <rsp stat="ok">
  <mediaid>abc123</mediaid>
  <mediaurl>http://twitpic.com/abc123&lt;/mediaurl&gt;
 </rsp>
*/

// Check for errors
if ([[request responseHeaders] objectForKey:@"stat"] != @"ok"){
 UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:@"TwitPic Submission" 
             message:[[request responseHeaders] objectForKey:@"mediaurl"]
               delegate:nil
            cancelButtonTitle:@"OK!" 
            otherButtonTitles:nil];
 [errorAlert show]; 
 [errorAlert release];
}

NSString *twitpicURL = [[request responseHeaders] objectForKey:@"mediaurl"];

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"TwitPic Submission" 
           message:twitpicURL
           delegate:nil
           cancelButtonTitle:@"OK!" 
           otherButtonTitles:nil];

I tried just dumping out [request responseString]... that's empty now also. That WAS showing a response, for sure.

As always, any help gratefully received. I'll give back once I'm able!

Cheers,

Jamie.

A: 

AH! I think I've found the problem. Seems to be a problem with TwitPic - 2 days ago I changed my password to a mixed-case one with numbers and letters. I just reset it back to an all lowercase one and... it all works fine.

I've sent a message to twitpic support - hopefully they'll look in to it!

Jamie.

badmanj
A: 

did you solve this? im also getting an empty response

A: 

Anyone ever solved this?

I checked contents of the responseHeaders dictionary and there simply was no mediaurl in it.

Used the following code:

for (id key in [request responseHeaders]) {

    NSLog(@"key: %@, value: %@", key, [[request responseHeaders] objectForKey:key]);

}

And that's what console showed:

2009-09-08 17:30:43.552 myApp[1989:207] key: X-Powered-By, value: PHP/5.2.9 2009-09-08 17:30:43.558 myApp[1989:207] key: Expires, value: Tue, 08 Sep 2009 17:30:25 GMT 2009-09-08 17:30:43.562 myApp[1989:207] key: Content-Encoding, value: gzip 2009-09-08 17:30:43.566 myApp[1989:207] key: Server, value: nginx/0.6.35 2009-09-08 17:30:43.569 myApp[1989:207] key: Content-Type, value: application/xml 2009-09-08 17:30:43.573 myApp[1989:207] key: Date, value: Tue, 08 Sep 2009 15:30:25 GMT 2009-09-08 17:30:43.577 myApp[1989:207] key: Connection, value: close

Any clues? Thanks in advance.

Friendlydeveloper
+2  A: 

OK, problem solved :-)

Check out this website: link text

Simply add these lines to your request:

[request setDidFinishSelector:@selector(requestDone:)];

[request setDidFailSelector:@selector(requestWentWrong:)];

and the following methods:

- (void)requestDone:(ASIHTTPRequest *)request { NSString *response = [request responseString];}
- (void)requestWentWrong:(ASIHTTPRequest *)request { NSError *error = [request error];}

NSString *response holds all the important feedback from twitpic.

Enjoy :-)

Friendlydeveloper
A: 

Has anyone managed to upload with the new documentation? I keep getting - invalid application key. Although it's just a copy pasted from the site. anyone with similar issues?

Asad Qamber
A: 

Same here, I'm also just getting back an empty response using the new twitpic api. Anybody else had some luck to get it working?