0
我正在創建一個PHP curl請求到服務器,期待一些字符串響應但沒有響應生成,這可能是什麼原因?從Curl請求到https服務器沒有響應
下面是相同的捲曲代碼:
$fields = array("username"=> 'xxx',"domain"=> 'xxx',"password" => 'xxx');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://host:8090/add-user");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $usr.':'.$pass);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
if(!$result=curl_exec($ch)){
trigger_error(curl_error($ch));
}
curl_close($ch);
var_dump($result);
下面是相同的等效命令行請求:
curl --data 'username=xxx&domain=xxx&password=xxx' https://host:8090/add-user -k -v -u 'usr:pass'
什麼,我做錯了什麼?
如果你var_dump()curl_error()消息會發生什麼? – Cups
得到沒有迴應,並沒有錯誤 – Ekansh