这是我的代码: 当我尝试连接到whm / Cpanel添加新帐户时出现此问题,但当我尝试从whm / cpanel删除用户时,它工作得很完美。 我的问题是curl_exec行死了,并向我显示空白屏幕,页面上没有任何错误,curl_error在curl_exec完全没有运行后没有返回任何代码。
感谢您的回答
$curl = curl_init();
# Create Curl Object
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
# Allow certs that do not match the domain
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
# Allow self-signed certs
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
# Return contents of transfer on curl_exec
$header[0] = "Authorization: WHM $cpanel_user:" . preg_replace("'(\r|\n)'", "", $whmhash);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 1800);
# Remove newlines from the hash
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
# Set curl header
curl_setopt($curl, CURLOPT_URL, $command);
# Set your URL
curl_setopt($curl, CURLOPT_FAILONERROR, FALSE);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
if( ! $result = curl_exec($curl))
{
trigger_error(curl_error($curl));
}
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
# Execute Query, assign to $result
if ($result == false) {
error_log("curl_exec threw error \"" . curl_error($curl) . "\" for $query");
}
curl_close($curl);
答案 0 :(得分:0)
您应该使用curl_errno来检查curl是否有任何错误
替换此
if( ! $result = curl_exec($curl))
{
trigger_error(curl_error($curl));
}
通过
$result = curl_exec($curl);
// Check for errors and display the error message
if($errno = curl_errno($curl)) {
$error_message = curl_strerror($errno);
trigger_error("cURL error ({$errno}):\n {$error_message}");
}
答案 1 :(得分:0)
问题是nginx不允许响应回到我的代码。 通过在服务于代理模式的服务器上禁用nginx来解决apache问题。