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.

API2, authenticate with api key instead of root user/pass?

Discussion in 'cPanel Developers' started by jspicher, May 19, 2011.

  1. jspicher

    jspicher Member

    Joined:
    May 19, 2011
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Hey guys,

    I'm using the cpanel xmlapi to automatically setup addon domains and l was wondering how l could use the cpanel api key to authenticate instead of the root username/password for the server.

    Here's the current code l'm using:

    PHP:
    <?php
    $subdomain 
    'addondomain.com';
    $username 'myusername';
    $password 'mypassword';


    require_once(
    'xmlapi.php');

    $xmlapi = new xmlapi('184.154.XXX.138');
    $xmlapi->password_auth("root"'ROOT_PASSWORD');

    $r $xmlapi->api2_query($username"AddonDomain""addaddondomain", array(subdomain => $subdomainnewdomain => $subdomaindir => $subdomainpass => $password));

    echo 
    '<pre>';
    print_r($r);

    ?>
    Any help would be greatly appreciated!
     
  2. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hi jspicher,

    I believe you're referring to the root accesshash. You can use that within PHP and with the xmlapi client class as follows

    PHP:
    $hash file_get_contents('/path/to/file/.accesshash');

    $xmlapi->set_user('root');
    $xmlapi->set_hash($hash);

    Regards,
    -DavidN
     
Loading...

Share This Page