0

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.

asked Apr 17, 2022 at 1:16

1 Answer 1

1

you can find the api here, on cPanel github: https://github.com/CpanelInc/publicapi-php

answered Apr 26, 2022 at 11:24
Sign up to request clarification or add additional context in comments.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.