How to HTTP POST a XML File using PHP without cURL? [duplicate]

亡梦爱人 提交于 2019-11-30 07:37:26
dprogramz

I think your POST array is wrong

Try:

$xml = file_get_contents('post_xml.xml');
$url = 'http://stg.sa.com/post.asmx/';


$post_data = array(
    "xml" => $xml,
);

$stream_options = array(
    'http' => array(
       'method'  => 'POST',
       'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
       'content' => http_build_query($post_data),
    ),
);

$context  = stream_context_create($stream_options);
$response = file_get_contents($url, null, $context);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!