如何將此代碼轉換爲curl命令?我想通過執行單個curl命令在linux機器上使用此代碼。將PHP代碼轉換爲curl命令,其中只允許TLSv1
$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);
我厭倦了這一個,但不成功:
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
也許問題是在HTTPS,因爲只有使用TLSv1被允許在網站上。
由curl或響應報告的任何錯誤? – NDM 2014-10-28 15:33:01
@NDM這是每次嘗試的響應: 401 Unauthorized>,來自php和瀏覽器一切正常 –
ibedelovski
2014-10-28 15:35:57
401意味着TLS層很好,但這意味着你沒有提供正確的HTTP認證。 – 2014-10-28 15:50:18