在PHP中将POST XML发送到URL
我有一个XML文件要通过POST发送到URL 这是我的代码:在PHP中将POST XML发送到URL,php,xml,Php,Xml,我有一个XML文件要通过POST发送到URL 这是我的代码: $url = "http://someurl.com"; $xml = file_get_contents('xml_api_actionsInsert_sample.xml'); $post_data = array('xml' => $xml); $stream_options = array( 'http' => array( 'method' => 'POST',
$url = "http://someurl.com";
$xml = file_get_contents('xml_api_actionsInsert_sample.xml');
$post_data = array('xml' => $xml);
$stream_options = array(
'http' => array(
'method' => 'POST',
'header' => 'ContentType: text/xml; charset=UTF8',
'content' => http_build_query($post_data)));
$context = stream_context_create($stream_options);
$response = file_get_contents($url, null, $context);
要求是标题内容类型必须为
并且请求只包含有效的XML。xml文件是有效的,但API中有一个错误
error: Request contains no XML
我如何发送/加载XML是否有错误?或者我应该尝试另一种发送请求的方式,比如cURL?您确定应该发送一个键值对xml=>?也许它希望你只发送XML字符串作为内容。@SergiuParaschiv,伙计,我是盲人,谢谢你,你能添加这个作为答案,这样我就可以接受它吗?
error: Request contains no XML