I am trying to start a small Twitter client and I encountered a problem while testing API calls requiring authentication.
My password has special characters, so when I try to use the following code, it does not work.
NSString *post = [NSString stringWithFormat:@"status=%@", [status stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; NSData *postData = [post dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]; NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]]; NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://%@:%@@%@/statuses/update.json", username, password, TwitterHostname]]; [request setURL:url]; [request setHTTPMethod:@"POST"]; [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; [request setHTTPBody:postData]; NSURLResponse *response; NSError *error; [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
I started learning base64 and put authentication in the headers. I found Dave Dribin's post about my base64 implementation, and that seemed to make sense. However, when I tried to use it, the compiler started complaining about how it could not find the openssl libraries. So I read that I need to link the libcrypto library, but it does not seem to exist for the iphone.
I also read people saying that an apple will not allow applications that use cryptographic libraries, it makes no sense to me.
So now I'm a little stuck and embarrassed. What is the easiest way to get basic authentication in my application?
Greetings
Meroon Jun 14 '09 at 18:23 2009-06-14 18:23
source share