iPhone sending POST with NSURLConnection

后端 未结 5 1930
萌比男神i
萌比男神i 2020-11-27 14:27

I\'m having some problems with sending POST data to a PHP script with NSURLConnection. This is my code:

    const char *bytes = [[NSString stringWithFormat:@         


        
5条回答
  •  庸人自扰
    2020-11-27 15:09

    POST data and XML data are not the same. You can send XML data just as you did, but the PHP code must parse the XML from the request body. PHP's xml_parse (http://php.net/manual/en/function.xml-parse.php) can help you do this.

    Alternatively, if you would prefer sending POST data, set the request body like this:

    const char *bytes = [[NSString stringWithFormat:@"mydata=%@", data] UTF8String];

提交回复
热议问题