Assist newbie: UAPI installation with Joomla

NickOg

Registered
Apr 12, 2021
3
0
1
Port Macquarie. NSW
cPanel Access Level
Website Owner
Hi
I am a very new user. We do use cPanel via our hosting service provider who have suggested that some work I need doing (creating email forwarding records) could best be handled vu UAPI and the add_forwarder functions. Fine - I can understand that.
The trouble is that my minimal code fails
Code:
function replaceMailForwarder($memberName, $personalEMail) {

  $forwarder = $memberName . '@conveners.pmhu3a.org.au';
  // Instantiate the CPANEL object.require_once "
  $cpanel = new CPANEL(); // Connect to cPanel - only do this once.
  echo '<p style="color:red;">$cPanel  ' . __LINE__ . ' ' . __FUNCTION__ . '<br />';
  var_dump($cPanel);
  echo '</p>';

// Delete the forwarder for [email protected]
  $delete_forwarder = $cpanel->uapi(
      'Email', 'delete_forwarder',
      array(
        'address' => $forwarder,
        'forwarder' => $personalEMail,
      )
  );
  echo '<p style="color:red;">$delete_forwarder  ' . __LINE__ . ' ' . __FUNCTION__ . '<br />';
  var_dump($delete_forwarder);
  echo '</p>';
  die(' dead at ' . __LINE__ . ' in ' . __FUNCTION__);
}
with
Code:
0 - Class 'CPANEL' not found
I assume that I need to install the UAPI library within Joomla.
Can anyone help with some pointers as to where to find and install that library?

Regards

Nick
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,519
1,029
313
cPanel Access Level
Root Administrator
Hey there! UAPI isn't something that gets installed, as it just exists on every cPanel system. I can't really advise how you'd integrate that with Joomla tools, but perhaps other users will be able to share their experience here.

Here's the documentation for creating a forwarder for this work:


which can just be called directly on the server's command line.

I'm also moving this thread to the development section of our forum for more attention.
 

NickOg

Registered
Apr 12, 2021
3
0
1
Port Macquarie. NSW
cPanel Access Level
Website Owner
Thanks for the reply. My problem is, I think, finding that UAPI! There seem to be several copies in Joomla components but none seem to work.
I look forward to other pointers from the forum
Nick
 

NickOg

Registered
Apr 12, 2021
3
0
1
Port Macquarie. NSW
cPanel Access Level
Website Owner
That is what I thought - built in.
But the problem is that if I I enter

$cpanel = new CPANEL();

I receive the error message " 0 - Class 'CPANEL' not found "

This within a Joomla form.

And I therefore assumed that I need PHP require_once('the location of UAPI');
That looks to be the way other Joomla components reference their own copies of the cPanel.php.


Nick
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,519
1,029
313
cPanel Access Level
Root Administrator
We have a nice article on using the API in scripts here:


which includes some examples using Curl, as well as setting up authentication tokens. I believe that would be a good place to start learning about the API integration process.