The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need help with liveAPI or similar

Discussion in 'cPanel Developers' started by ipftp, Mar 23, 2017.

  1. ipftp

    ipftp Registered

    Joined:
    Mar 23, 2017
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    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?
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,094
    Likes Received:
    1,288
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    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.
     
  3. Amine Dehbi

    Amine Dehbi Registered

    Joined:
    Jun 1, 2017
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    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" ]); 
     
    #3 Amine Dehbi, Jun 1, 2017
    Last edited by a moderator: Jun 1, 2017
Loading...

Share This Page