如何将此 php 代码转换为 curl 命令?我想通过执行单个 curl 命令在 linux 机器上使用此代码。
$headers = array(
"Content-type: text/xml",
"Content-length: " . strlen($xml)
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10000);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = curl_exec($ch);
Run Code Online (Sandbox Code Playgroud)
我厌倦了这个,但没有成功:
curl -X POST -H "Content-type: text/xml" -o output.txt -d "param1=param1&username=username&password=password" https://site.url.com -d @data.xml
Run Code Online (Sandbox Code Playgroud)
也许问题出在 HTTPS 上,因为站点上只允许使用 TLSv1。