我正在尝试向我自己的服务器执行cURL请求,它似乎已超时。我累了添加session_write_close();根据本网站的建议。然而,这仍然存在错误。
以下是我正在使用的代码:
$whmusername = "root";
$whmhash = "MY LONG HASH IS IN HERE ON THE ACTUAL SCRIPT :)";
# some hash value
$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 $whmusername:" . preg_replace("'(\r|\n)'","",$whmhash);
# Remove newlines from the hash
curl_setopt($curl,CURLOPT_HTTPHEADER,$header);
# Set curl header
curl_setopt($curl, CURLOPT_URL, $query);
# Set your URL
//session_write_close();
$result = curl_exec($curl);
# Execute Query, assign to $result
if ($result == false) {
error_log("curl_exec threw error \"" . curl_error($curl) . "\" for $query");
}
curl_close($curl);
print $result;