用于发布xml文件的curl -i -k -H'Content-type:text / xml'-d'的相应PHP curl设置是什么

时间:2012-03-23 07:48:56

标签: php xml curl

“curl -i -k -H”Content-type:text / xml'-d'的相应PHP curl设置是什么? 用于将xml文件发布到服务器?

2 个答案:

答案 0 :(得分:0)

  • -iCURLOPT_HEADER = true
  • -kCURLOPT_SSL_VERIFYPEER = false
  • -H 'Content-type: text/xml'CURLOPT_HTTPHEADER = ['Content-type: text/xml']
  • -dCURLOPT_POST = true

要设置这些选项,请使用curl_setopt_array()

curl_setopt_array($curl, array(
    CURLOPT_HEADER => true,
    CULROPT_SSL_VERIFYPEER => false,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => array('Content-type: text/xml')
));

答案 1 :(得分:-1)

if ($ch = curl_init()) {
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_URL, $URL);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, array(
       'filename'=>'@/path/to/file'
    ));

    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-type: text/xml'
    ));


    $out = curl_exec($ch);
}