我试图在php中发出 Curl 请求。我开始通过命令行这样做:curl -k -X "POST" -d "{\"_format\":\"json\",\"id\":\"152\",\"subscription_type\":\"TEST\"}" -H "Content-type:\ application/json" -H "Accept:\ application/json" https://url
现在我需要在 PHP 中创建它,但我不知道 -k (关闭证书验证)选项中的等价物是什么强> PHP
但是我尝试了一些事情:
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $data,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_SSL_VERIFYPEER => false
));
答案 0 :(得分:3)
curl的-k
选项实际上将两个不同的选项设置为false。它disables the check of the signature in the cert,disables the check of the host name in the cert:
CURLOPT_SSL_VERIFYPEER => false
CURLOPT_SSL_VERIFYHOST => false