我想從我的iPhone應用程序發送一些數據作爲數組服務器發送POST陣列
當我張貼單變量我是送崗位作爲一個NSString
NSString *post =[[NSString alloc] initWithFormat:@"userName=%@&accountID=%@&",
username,accId];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[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];
現在我想之前發送這些用戶名和accountIds的數組,我如何發送一個NSArray在POST中,然後在我的服務器上的PHP如何檢索它?
感謝
+1 JSON是我想要的使用時節省一些流量。 – 2010-08-26 13:08:50