“curl -i -k -H”Content-type:text / xml'-d'的相应PHP curl设置是什么? 用于将xml文件发布到服务器?
答案 0 :(得分:0)
-i
:CURLOPT_HEADER = true
-k
:CURLOPT_SSL_VERIFYPEER = false
-H 'Content-type: text/xml'
:CURLOPT_HTTPHEADER = ['Content-type: text/xml']
-d
:CURLOPT_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);
}