我有一个 curl 请求,它在我的本地主机中运行良好,我已将它上传到服务器,但它挂起并以错误 500 内部服务器错误结束。如果删除该行echo $output = curl_exec($ch);
它工作正常。
$url = "https://someserver.com/api/";
$username = "some_user";
$password = "some_apss";
if(!extension_loaded('curl')){
die("Curl extension not loaded");
}
if(!function_exists('curl_init')){
die("curl_init not found");
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
echo $output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);`