Sending XML data using HTTP POST with PHP

后端 未结 2 2020
感情败类
感情败类 2020-11-28 09:14

I need to send this XML

      

   NO
   1900&         


        
2条回答
  •  温柔的废话
    2020-11-28 10:04

    Another option would be file_get_contents():

    // $xml_str = your xml
    // $url = target url
    
    $post_data = array('xml' => $xml_str);
    $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);
    

提交回复
热议问题