Using curl, however my array will not post and content-type header does not send

tyncseectm7

New Member
Here's my code for performing the POST:\[code\]$url = "http://www.xxxxxxxxxxx.com/dfeed/index.cfm"; //where to send it$ch = curl_init();curl_setopt($ch, CURLOPT_VERBOSE, 1); // set url to post tocurl_setopt($ch, CURLOPT_URL, $url); // set url to post tocurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variablecurl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml; charset=ISO- 8859-1'));curl_setopt($ch, CURLOPT_HEADER, 1);curl_setopt($ch, CURLOPT_TIMEOUT, 40); // times out after 4scurl_setopt($ch, CURLOPT_POSTFIELDS, $data); // add POST fieldscurl_setopt($ch, CURLOPT_POST, 1);$result = curl_exec($ch); // run the whole processecho $result;//echo curl_getinfo($ch, CURLINFO_HTTP_CODE);curl_close ($ch);\[/code\]My post array starts out with the same few (manually defined) entries like this:\[code\]$data[0] = "<?xml version='1.0' encoding='ISO-8859-1'?>\n";$data[1] = "<rss xmlns:g='http://base.google.com/ns/1.0' version='2.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'\[/code\]xsi:noNamespaceSchemaLocation='http://www.xxxxx.com/dFeed/schemas/FeedSchema1.0.xsd'>\n";The rest of them are populated in a loop like this:\[code\]array_push($data, "\t<item>\n");\[/code\]The response from the server indicates a different content-type from what I have set, and also indicates it received no information so something must be wrong:\[code\]HTTP/1.1 400 Bad Request Transfer-Encoding: chunked Content-Type: text/htmlServer: Microsoft-IIS/7.0 X-XXX Server: Web2 Date: Mon, 25 Jun 2012 12:49:53 GMT Bad RequestError: Not XMLContent received: \[/code\]
 
Back
Top