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.

cpsess of cPanel Secure Remote Login

Discussion in 'cPanel Developers' started by jose eduardo, Oct 17, 2016.

  1. jose eduardo

    jose eduardo Registered

    Joined:
    Oct 17, 2016
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    brazil
    cPanel Access Level:
    Reseller Owner
    i'm starting on cPanel API and have a problem, this is my code:

    $user = 'username';
    $pass = 'password';
    $host = 'xxx.xxx.xxx.xxx';

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $host);
    $header[0] = "Authorization: Basic " . base64_encode($user . ":" . $pass) . "\n\r";
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_PORT, 2083);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "user=$user&pass=$pass");
    curl_setopt($ch, CURLOPT_TIMEOUT, 100020);

    $f = curl_exec($ch);
    $h = curl_getinfo($ch);

    echo $h['url'];

    curl_close($ch);

    this code show: "https://server.mydomain.com:2083/frontend/paper_lantern/index.html".

    I need "cpsessxxxxxxxxx" for the correct link.

    OBS: I searched here and see some topics, i tried some codes, but dont work... please if someone have a solution, help me if possible. Thanks all :) and have a nice day
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    649
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello,

    The following document offers information about authenticating when using our API:

    Guide to API Authentication - Software Development Kit - cPanel Documentation

    Review the "Single Sign On" and "Secure Remote Logins" section to determine which option works best for the custom script you are developing.

    We're happy to provide further clarifications, or answer any additional questions you have.

    Thanks!
     
Loading...

Share This Page