0

POSTを実行するための私のコードは次のとおりです。

$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 to
curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
curl_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 4s
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); // add POST fields
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch); // run the whole process
echo $result;
//echo curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close ($ch);

私の投稿配列は、次のような同じいくつかの (手動で定義された) エントリから始まります。

$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'

xsi:noNamespaceSchemaLocation='http://www.xxxxx.com/dFeed/schemas/FeedSchema1.0.xsd'>\n";

それらの残りは、次のようなループで設定されます。

array_push($data, "\t<item>\n");

サーバーからの応答は、設定したものとは異なる content-type を示しており、情報を受信して​​いないことも示しているため、何かが間違っているに違いありません。

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 Request
Error: Not XML
Content received: 
4

1 に答える 1