Need help with liveAPI or similar

ipftp

Registered
Mar 23, 2017
1
0
1
Denmark
cPanel Access Level
Reseller Owner
Hi

I have bought a reseller account at domain.ca - but not because I want to run a web host site.
I Run a website where the user can store images from survailance cameras. I run something manually at the moment - but I would like to run somethings automatic/dynamically.

Actually all I need is to be able to create the following when I have a new customer (the customer register in Wordpress/woo commerce)

1) create a new sub domain
2) create a ftp account for this sub domain
3) create a cron job.

Maybe I can use LiveAPI? - but I can't figure out how to Instantiate the CPANEL object?
How can I do this?
require_once "/usr/local/cpanel/php/cpanel.php";
And where shall I put the php files to use LiveAPI

Am I way off or is there an easier way?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,202
363
Actually all I need is to be able to create the following when I have a new customer (the customer register in Wordpress/woo commerce)

1) create a new sub domain
2) create a ftp account for this sub domain
3) create a cron job.
Hello,

The following API functions are available for these actions:

cPanel API 2 Functions - SubDomain::addsubdomain - Software Development Kit - cPanel Documentation
UAPI Functions - Ftp::add_ftp - Software Development Kit - cPanel Documentation
cPanel API 2 Functions - Cron::add_line - Software Development Kit - cPanel Documentation

If you are integrating these functions with a PHP script, you might consider using the PHP client class:

GitHub - CpanelInc/xmlapi-php: A PHP Class for Interacting with cPanel's XML-API

Thank you.
 

Amine Dehbi

Registered
Jun 1, 2017
1
0
1
Morocco
cPanel Access Level
Root Administrator
I have already created a PHP Class to easily use the cPanel/WHM API.

you can found it here : - Removed -

For example if you want to add a subdomain to an account :
Code:
<?php
include_once 'src/cPanel.php';

$app = new cPanel();

$app->cPanelApi('username', 'SubDomain', addsubdomain, ['domain' => 'subdomain', 'rootdomain' => 'domain.com', 'dir' => "/public_html/directory_name" ]);
 
Last edited by a moderator: