0
我已经尝试了很多方法,但我仍然在服务器端获得一个空数组。我想将xml数据发布到服务器端php文件
这里是我的代码:
NSString *urlString = [[NSString alloc] initWithFormat:@"%@/test.php", APP_WEBSITE_URL];
NSURL *requestURL = [NSURL URLWithString:urlString];
NSMutableURLRequest *requestObj = [NSMutableURLRequest requestWithURL:requestURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
[requestObj setHTTPMethod:@"POST"];
[requestObj setValue:@"application/xml" forHTTPHeaderField:@"Content-Type"];
NSInteger tmpCount = [strawPollDetailItem.selectionsArray count];
NSMutableData *postBody = [NSMutableData data];
[postBody appendData:[[NSString stringWithFormat:@"<SUBMITTED>"] dataUsingEncoding:NSUTF8StringEncoding]];
for (int i=0; i<tmpCount; i++) {
NSInteger selectedID = [strawPollDetailItem.selectionsArray objectAtIndex:i];
[postBody appendData:[[NSString stringWithFormat:@"<OPTIONID>%@</OPTIONID>", selectedID] dataUsingEncoding:NSUTF8StringEncoding]];
}
[postBody appendData:[[NSString stringWithFormat:@"</SUBMITTED>"] dataUsingEncoding:NSUTF8StringEncoding]];
[requestObj setHTTPBody:postBody];
[[NSURLConnection alloc] initWithRequest:requestObj delegate:self];
你为什么不尝试做自己的一些工作,而不是采取了答案[别人给你(http://stackoverflow.com/questions/11394933/i-am-try-to-post-the-xml-data-to-server-side-php-file)并重新发布,请求某人完成下一部分工作。花时间学习东西。我们在这里帮助你,而不是为你做你的工作。 – 2012-07-09 12:30:52