Php 未过帐的Curl POST字段
我已经验证了Php 未过帐的Curl POST字段,php,curl,Php,Curl,我已经验证了$requestDom->saveXml()正在返回有效的XML,但是在目标URL上我有print\r($\u POST),它没有收到任何内容。我是不是遗漏了什么-\ $connection = curl_init(); curl_setopt($connection, CURLOPT_POSTFIELDS, array( 'xml' => $requestDom->saveXml() )); curl_setopt($co
$requestDom->saveXml()
正在返回有效的XML,但是在目标URL上我有print\r($\u POST),它没有收到任何内容。我是不是遗漏了什么-\
$connection = curl_init();
curl_setopt($connection, CURLOPT_POSTFIELDS, array(
'xml' => $requestDom->saveXml()
));
curl_setopt($connection, CURLOPT_HEADER, false); //with or without this option, it doesn't work
curl_setopt($connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($connection, CURLOPT_POST, true);
curl_setopt($connection, CURLOPT_URL, 'http://sample.com');
$response = curl_exec($connection);
我可以重现这个问题。在EFnet上的#php.pecl频道寻求帮助。经过进一步研究,我发现将xml发布到目标URL的正确方法是
$connection = curl_init();
curl_setopt($connection, CURLOPT_POSTFIELDS, $requestDom->saveXml());
curl_setopt($connection, CURLOPT_HEADER, false); //with or without this option, it doesn't work
curl_setopt($connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($connection, CURLOPT_POST, true);
curl_setopt($connection, CURLOPT_URL, 'http://sample.com');
$response = curl_exec($connection);
然后在接收此信息的文件上,使用:
$post = file_get_contents("php://input");
$request = simplexml_load_string($post);