如何将命令行cURL转换为PHP cURL?

时间:2016-10-03 11:28:08

标签: php curl

我有命令

Todos.create()

在php发送

curl -v -X POST -H "Content-Type: application/xml" -d @case.xml --user test:test url

但此代码不起作用,$ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml')); curl_setopt($ch, CURLOPT_USERPWD, "test:test"); curl_setopt($ch, CURLOPT_POSTFIELDS, ['data' => new CurlFile('case.xml')]); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); $result = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch);

Web服务器使用基本HTTP身份验证。我正在使用7.0.11

1 个答案:

答案 0 :(得分:0)

class="display nowrap" cellspacing="0" width="100%"

这是工作