jose eduardo

Registered
Oct 17, 2016
1
0
1
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
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463
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!