views:

62

answers:

0

I'm unable to get this to work:

NSString *post = [NSString stringWithFormat:@"userudid=%@", [udid stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

NSLog(@"%@",post);
NSData *postData = [NSData dataWithBytes:[post UTF8String] length:[post length]]; 
//[udid dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];

NSLog(@"%@",postData);
//NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];

NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.myserver.com/myapp/readtags2.php"]];
[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;
NSData *urlData = [NSURLConnection sendSynchronousRequest:request 
    returningResponse:&response error:&error];

NSString *content = [NSString stringWithUTF8String:[urlData bytes]];
NSLog(@"responseData: %@", content);

is the POST formed correctly? Because i can get it to work from a manual html form posting to the same php file, but i get nothing back when doing it from iOS