sorry if my question might sound silly. I am trying to create an email address with Cpanel UAPI with LiveAPI.php but I seem to be lost on some codes.
The documentation to create email address is gotten from https://api.docs.cpanel.net/openapi/cpanel/operation/add_pop/
I use this code according to the docs
<?php
//--------------------------------------------------------------------------------------
// Instructions:
//--------------------------------------------------------------------------------------
// 1) cd /usr/local/cpanel/base/frontend/paper_lantern
// 2) mkdir api_examples
// 3) cd api_examples
// 4) create a file Email_add_pop.live.php and put this code into that file.
// 5) In your browser login to a cPanel account.
// 6) Manually change the url from: .../frontend/paper_lantern/
// to .../frontend/paper_lantern/api_examples/Email_add_pop.live.php
//--------------------------------------------------------------------------------------
// Instantiate the CPANEL object.
require_once "/usr/local/cpanel/php/cpanel.php";
// Print the header
header('Content-Type: text/plain');
// Connect to cPanel - only do this once.
$cpanel = new CPANEL();
// Call the API
$response = $cpanel->uapi(
'Email',
'add_pop',
array (
'email' => 'zomba',
'password' => '123456luggage',
'domain' => 'example.com',
'quota' => 'unlimited',
'send_welcome_email' => '1',
'skip_update_db' => '0',
)
);
// Handle the response
if ($response['cpanelresult']['result']['status']) {
$data = $response['cpanelresult']['result']['data'];
// Do something with the $data
// So you can see the data shape we print it here.
print to_json($data);
}
else {
// Report errors:
print to_json($response['cpanelresult']['result']['errors']);
}
// Disconnect from cPanel - only do this once.
$cpanel->end();
//--------------------------------------------------------------------------------------
// Helper function to convert a PHP value to html printable json
//--------------------------------------------------------------------------------------
function to_json($data) {
return json_encode($data, JSON_PRETTY_PRINT);
}
WHAT I DO NOT UNDERSTAND IS FROM
HERE
<?php
//--------------------------------------------------------------------------------------
// Instructions:
//--------------------------------------------------------------------------------------
// 1) cd /usr/local/cpanel/base/frontend/paper_lantern
// 2) mkdir api_examples
// 3) cd api_examples
// 4) create a file Email_add_pop.live.php and put this code into that file.
// 5) In your browser login to a cPanel account.
// 6) Manually change the url from: .../frontend/paper_lantern/
// to .../frontend/paper_lantern/api_examples/Email_add_pop.live.php
//--------------------------------------------------------------------------------------
// Instantiate the CPANEL object.
require_once "/usr/local/cpanel/php/cpanel.php";
?>
STOPS HERE.
WHERE DO I FIND
require_once "/usr/local/cpanel/php/cpanel.php";
I DONT UNDERSTAND THAT LINE.
I saw this forum post https://forums.cpanel.net/threads/using-cpanel-uapi-in-from-my-php.672337/ that had my exact issues, but after reading it, I got more confused, following the links for more help, the resulting page is depreciated.
I checked Stackoverflow cpanel-uapi tag here https://stackoverflow.com/questions/tagged/cpanel-uapi no answer
Please who has an idea on what I need to learn or install or set properly.
you can find the api here, on cPanel github: https://github.com/CpanelInc/publicapi-php