Srikanth79

Member
Dec 29, 2015
12
0
1
India
cPanel Access Level
Root Administrator
Hello,

I am trying this code from Guide to API Authentication - Software Development Kit - cPanel Documentation

Code:
<?
$whmusername = "root";
# The contents of /root/.accesshash
$hash = "accesshashhere";
$query = "http://xxx.xx.x.xxx:2086/json-api/listaccts?api.version=1";
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
$header[0] = "Authorization: WHM $whmusername:" . preg_replace("'(\r|\n)'","",$hash);
curl_setopt($curl,CURLOPT_HTTPHEADER,$header);
curl_setopt($curl, CURLOPT_URL, $query);
$result = curl_exec($curl);
if ($result == false) {
error_log("curl_exec threw error \"" . curl_error($curl) . "\" for $query");
}
curl_close($curl);
print $result;
?>
But I am getting :
curl_exec threw error "Failed to connect to xxx.xx.x.xxx port 2086: Connection timed out" for https://xxx.xx.x.xxx:2086/json-api/listaccts?api.version=1

Orginating the request from wiredtree and trying to connect to a WHM on knownhost.

Any idea? Thanks...