The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WHM api connection problem

Discussion in 'cPanel Developers' started by Srikanth79, Dec 29, 2015.

  1. Srikanth79

    Srikanth79 Member

    Joined:
    Dec 29, 2015
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    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...
     
  2. Srikanth79

    Srikanth79 Member

    Joined:
    Dec 29, 2015
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hello, I was able to connect to port 80 but not 2086
     
  3. Srikanth79

    Srikanth79 Member

    Joined:
    Dec 29, 2015
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Never mind, outgoing connections to port 2086 were blocked.
     
  4. cPDavidN

    cPDavidN cPanel Developer
    Staff Member

    Joined:
    Mar 19, 2013
    Messages:
    42
    Likes Received:
    3
    Trophy Points:
    8
    cPanel Access Level:
    DataCenter Provider
    Adding [SOLVED] to the thread title. Thanks for your help!
     
Loading...

Share This Page