如何使用POST php将XML文件发送到外部URL

时间:2017-02-25 17:08:52

标签: php xml curl

我尝试了几个小时,卷曲功能不起作用。也许我还没有正确使用它。

<i>$url = "https://urltosend.com/ext_interface.php?b=update_customer";
  $xmldatafile="JOBS.xml"; 
  function postData($postFileds,$url){ 
            $ch = curl_init(); 
            curl_setopt($ch, CURLOPT_URL, $url); 
            curl_setopt($ch, CURLOPT_POST ,1); 
            curl_setopt($ch, CURLOPT_POSTFIELDS ,$postFileds); 
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1); 
            curl_setopt($ch, CURLOPT_HEADER ,0); 
            curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1); 
            $data = curl_exec($ch); 
            curl_close($ch); 
            return $data; 
    } 
 $xmlData = file_get_contents("JOBS.xml"); 
 #echo $xmlData; 
 #$postFileds = 'data='. urlencode($xmlData); 
 $postFileds = 'data='.$xmldatafile; 

 $result = postData($postFileds,"https://urltosend.com/ext_interface.php?b=update_customer"); 
    $result;</i>

请帮忙。

0 个答案:

没有答案