我试图将带有身份验证标头的 curl 语句转换为 php curl 请求。但它似乎不起作用,因为我收到以下错误echo 'error:' . curl_error($ch);
:
error:SSL certificate problem: unable to get local issuer certificate
我的 curl 命令如下所示:
curl --user XXXX:YYYY "URL"
我的 php-curl 看起来像这样:
$login = 'XXXX';
$password = 'YYYY';
$url = 'URL';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$login:$password");
echo curl_exec($ch);
$result = curl_exec($ch);
if ($result != false){
echo "SUCCESS";
}else{
echo "<br>";
echo 'error:' . curl_error($ch);
echo "<br>";
}
curl_close($ch);
echo($result);
有人看出我的错吗?