Php 使用post服务将数组发送到服务器而不附加到url

Php 使用post服务将数组发送到服务器而不附加到url,php,objective-c,post,Php,Objective C,Post,您好,我正在尝试向服务器发送一个数组,但没有将其附加到url,但它没有发生 NSMutableDictionary *dict=[[NSMutableDictionary alloc]init]; [dict setObject:@"Kiran" forKey:@"name"]; [dict setObject:@"kumar" forKey:@"lName"]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init

您好,我正在尝试向服务器发送一个数组,但没有将其附加到url,但它没有发生

 NSMutableDictionary *dict=[[NSMutableDictionary alloc]init];
[dict setObject:@"Kiran" forKey:@"name"];
[dict setObject:@"kumar" forKey:@"lName"];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://192.168.0.125/vblive_new/api/getMobileContactList?"]];

[request setHTTPMethod:@"POST"];

NSMutableDictionary *jsonDict = [[NSMutableDictionary alloc] init];
[jsonDict setValue:dict forKey:@"userName"];
NSLog(@"JSON Dict: %@",jsonDict);//Check your array here...


NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict options:NSJSONWritingPrettyPrinted error:nil];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSString *postLength = [NSString stringWithFormat:@"%lu", (unsigned long)[jsonData length]];
NSLog(@"JSON String: %@",jsonString); //Check your post String here...
NSLog(@"post length is %@",postLength);
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:@"json" forHTTPHeaderField:@"Data-Type"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:jsonData];

conn = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:true];

也许您的程序提前完成,请求将被发送。尝试发送同步请求可能您的程序提前完成,请求将被发送。尝试发送同步请求