Thank you.
- XML-like output of APIs
The XML-like output of our API (often called the XML API) is already officially deprecated, and cPanel & WHM Version 70 will be the last version to support this output. Integrators and API users will want to begin switching to use the JSON output of the API now. The XML-like format has long caused problems for integrators and developers because it is not valid XML, and we find that removing it completely will help reduce that.
This may be related to this:Even on the page you link EVERY SINGLE link is broken and redirects (301 Moved Permanently) to /DD.
Hello,
If the custom script you are developing is hosted on a remote server, then you'd need to configure the script to connect to the IP address of the cPanel server as opposed to "localhost" or "127.0.0.1". We provide a list of available authentication methods at:
Guide to API Authentication - Developer Documentation - cPanel Documentation
Additionally, if you plan to develop your script in PHP, you may find the following user-submitted UAPI PHP class helpful:
UAPI PHP Class
Thank you.
Hello,But for cpanel, am not so sure. The links below treated Hash, Username & Password but gave examples with WHM, could you please use any cpanel call, like maybe 'addpop' to make an example. So that I can see how cpanel is authenticated.
<?
$whmusername = "username123";
$whmpassword = "password12345";
$query = "https://127.0.0.1:2083/execute/Email/list_pops";
$curl = curl_init(); // Create Curl Object
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0); // Allow self-signed certs
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0); // Allow certs that do not match the hostname
curl_setopt($curl, CURLOPT_HEADER,0); // Do not include header in output
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1); // Return contents of transfer on curl_exec
$header[0] = "Authorization: Basic " . base64_encode($whmusername.":".$whmpassword) . "\n\r";
curl_setopt($curl, CURLOPT_HTTPHEADER, $header); // set the username and password
curl_setopt($curl, CURLOPT_URL, $query); // execute the query
$result = curl_exec($curl);
if ($result == false) {
error_log("curl_exec threw error \"" . curl_error($curl) . "\" for $query");
// log error if curl exec fails
}
curl_close($curl);
print $result;
?>
$query = "https://127.0.0.1:2083/execute/Email/list_pops";
Thank you so much.Hello,
The Access Hash Authentication method is only available for WHM authentication. If you are looking to authenticate with the cPanel username and password, then you'd need to modify the example provided on Username and Password Authentication document so that it uses the cPanel username, password, port, and UAPI link. EX:
As far as the following line:Code:<? $whmusername = "username123"; $whmpassword = "password12345"; $query = "https://127.0.0.1:2083/execute/Email/list_pops"; $curl = curl_init(); // Create Curl Object curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0); // Allow self-signed certs curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0); // Allow certs that do not match the hostname curl_setopt($curl, CURLOPT_HEADER,0); // Do not include header in output curl_setopt($curl, CURLOPT_RETURNTRANSFER,1); // Return contents of transfer on curl_exec $header[0] = "Authorization: Basic " . base64_encode($whmusername.":".$whmpassword) . "\n\r"; curl_setopt($curl, CURLOPT_HTTPHEADER, $header); // set the username and password curl_setopt($curl, CURLOPT_URL, $query); // execute the query $result = curl_exec($curl); if ($result == false) { error_log("curl_exec threw error \"" . curl_error($curl) . "\" for $query"); // log error if curl exec fails } curl_close($curl); print $result; ?>
I recommend enabling the following option under the "System" tab in "WHM >> Tweak Settings":Code:$query = "https://127.0.0.1:2083/execute/Email/list_pops";
cPanel & WHM API shell (for developers)
This will allow you to access the "API Shell" option from within cPanel for an account with reseller privileges (you can create a test account for this purpose). The API Shell option in cPanel will help you formulate the correct URL.
The following document is a good place to start:1.How can I make my server secure for production, I.e hosting site for my clients.
Or better still what are the basic settings in need to put in place in WHM for my server to be secure considering that I should be able to use cpanel and WHM api.
You can run WHM API 1 functions as root or as a reseller, as long as the the reseller has the corresponding feature assigned as a privilege. The reseller skeleton directory is located in a separate location compared to the root skeleton directory:3. If I signup for the vps using mysite.com for example, I found out that in mysite.com I can use the WHM api1 to create cpanel accounts, following the Tweak setting you mentioned above. But I will need more than one skeleton directory, that necessitated my need to create a reseller. But i was unable to locate /root/cpanel-skel-3 in neither mysite.com nor its reseller. How can I solve this issue?
And must I only run this WHM api in mysite.com can I run it in another site I created maybe a reseller, and then provide the root hash?
Hello,- Am trying to call that function from WHM just like i have been doing to others with success, but for this fileman::upload_files function, i keep getting "You must specify at least one file to upload."
You'd need to run that UAPI function as the cPanel user. The Single Sign On method would allow you to authenticate as the cPanel user without using the account password:This is by design. We disallow file uploads since the form is parsed (and the file stored in a temporary file) before privileges are dropped. When we go to actually run the function call as the user, the file is not accessible. We have to parse the form before dropping privileges in order to know what user we need to run as.