Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

How to use UAPI?

Discussion in 'cPanel Developers' started by KuroiNekoDev, Mar 7, 2018.

Tags:
  1. KuroiNekoDev

    KuroiNekoDev Registered

    Joined:
    Mar 3, 2018
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Nowhere
    cPanel Access Level:
    Reseller Owner
    Hi, I'm working with API2 (in PHP using this class) but, as I need to use suspend_login, suspend_incoming and suspend_outgoing and they are available only in UAPI I will need to migrate verything to UAPI but.... how I do it?

    This is an example of my codes...

    cP_config.php
    PHP:
        define('cP_user''********');        # user
        
    define('cP_pass''********');        # password
        
    define('cp_svIP''********');        # server IP (don't care if it's public or shared IP)
        
    define('cP_port''2083');            # default: 2083 (https)

        ## cP-API class
        
    require('xml_api.php');

        
    ## Connection to server
        
    $xmlapi  = new xmlapi(cp_svIP);
        
    $xmlapi -> set_port(cP_port);
        
    $xmlapi -> password_auth(cP_user,cP_pass);
        
    $xmlapi -> set_output('json');
        
    $xmlapi -> set_debug(0);
    and one of my codes from cP_functions.php
    PHP:
        $cPanel json_decode($xmlapi->api2_query(
            
    cP_user'Email''addpop',
            array(
                
    'domain'    => $json->email_domain,
                
    'email'     => $json->email_name,
                
    'password'  => $json->email_pass,
                
    'quota'     => $json->email_quota
            
    )
        ), 
    true);

        if(
    $cPanel['cpanelresult']['data'][0]['result']){
            
    $data['success'] = true;
            
    $data['msg'] = 'Email created successfully.';
        } else {
            
    $data['msg'] = 'Nope. (cP error: '$cPanel['cpanelresult']['error'] .' )';
        }


    How I make the change? Where can I get the UAPI-PHP library, and will this change the connections and the syntax of my codes?
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,870
    Likes Received:
    1,811
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Here's a user-submitted PHP class for UAPI that you may find helpful:

    UAPI PHP Class

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    KuroiNekoDev likes this.
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice