This piece of code does not work, I get an "Authentication Error" message. response from the server. Any ideas?
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString:@"http://www.tumblr.com/api/write"]]; [request setHTTPMethod:@"POST"]; [request addValue:_tumblrLogin forHTTPHeaderField:@"email"]; [request addValue:_tumblrPassword forHTTPHeaderField:@"password"]; [request addValue:@"regular" forHTTPHeaderField:@"type"]; [request addValue:@"theTitle" forHTTPHeaderField:@"title"]; [request addValue:@"theBody" forHTTPHeaderField:@"body"]; NSLog(@"Tumblr Login:%@\nTumblr Password:%@", _tumblrLogin, _tumblrPassword); [NSURLConnection connectionWithRequest:request delegate:self]; [request release];
Both _tumblrLogin and _tumblrPassword are executed via stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding elsewhere in my code. My email address is in the form "address+test@test.com". It works great for logging directly into tumblr, but I wonder if the "+" character causes encoding problems? This did not slip away. Should it be?
Thanks to Martin's suggestion, I am now using CFURLCreateStringByAddingPercentEscapes to avoid entering a username and password. I still have the same problem, although my authentication does not work.
cocoa tumblr nsmutableurlrequest
kubi
source share