我该如何将这个curl命令翻译成适用于PHP脚本的形式?
curl --request POST --data-binary '@import.xml' --header "Content-Type: application/atom+xml" --header "Content-Length: 378" "http://url.com"
这个不起作用:
$data = array('file'=>$filename);
$headers = array(
'Content-Type: application/atom+xml',
'Content-Length: 378'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, 'httpL//url.com');
curl_setopt($ch, CURLOPT_BINARYTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_exec($ch);