Hi,
I'm trying to get the following code to run (it's from the Heads First iPhone Development book - page 81), it's a twitter app, and the code blow runs when you press a button to send a simple text message to twitter:
//TWITTER BLACK MAGIC
NSMutableURLRequest *theRequest=[NSMutableURLRequest
requestWithURL:[NSURL URLWithString:@"http://username:[email protected]/statuses/update.xml"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval: 60.0];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[[NSString stringWithFormat:@"status=%", themessage] dataUsingEncoding:NSASCIIStringEncoding]];
NSURLResponse* response;
NSError* error;
NSData* result = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:&error];
NSLog(@"%@", [[[NSString alloc] initWithData:result encoding:NSASCIIStringEncoding] autorelease]);
//END TWITTER BLACK MAGIC
and it does to a certain extent i.e the code runs but you can't see the result on Twitter - the resopnse I get back from Twitter in the debug window is:
<request>/statuses/update.xml</request>
<error>Client must provide a 'status' parameter with a value.</error>
Any ideas?