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.

Help please :( The class does not work

Discussion in 'cPanel Developers' started by jgames88, Aug 26, 2010.

  1. jgames88

    jgames88 Registered

    Aug 26, 2010
    Likes Received:
    Trophy Points:
    I have tried all, put all and nothig i used this class xmlapi and it did not work, it did not show a mistake but it did not do anything, I want to create a instantly subdomain with this class but i havenĀ“t been able to.. please help.. i used this:
    $ip "";
    $account "username";
    $password "passoword";

    $xmlapi = new xmlapi($ip);

    $args = array(
    domain=> "subdomain"
    rootdomain=> "domain",
    dir => "public_html/"

    $xmlapi->api2_query($account"SubDomain""addsubdomain"$args );
    with xmlapi but it did not work, what is it happening? :(, maybe is it the IP? what IP is that? i do not get that i keep like that..
    #1 jgames88, Aug 26, 2010
    Last edited: Aug 26, 2010
  2. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Dec 17, 2009
    Likes Received:
    Trophy Points:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hi jgames88,

    The code example you provided should work fine as far as creating the subdomain. However, there's one technical error that I'm surprised didn't throw a warning. The query methods ("xmlapi_query", "api1_query", and "api2_query") all return a SimpleXML object by default. So, in you last line you're using a "print" statement on an object, which is likely to fail in this particular case. If you want to see the results, as a whole, either do "var_dump($result)" or "print $result->asXML()" or "echo $result->asXML()"

    The variable "$ip" is the IP address of the machine that hosts your account. If you're invoking you script on the server that has you account, you can leave it with ''. That particular address is a loopback; it just points to the localhost, e.g. the server you're on.

    What is the exact output of that? If you're invoking that code on a cPanel box, the debug output is likely going to the cPanel error_log. If you're running on a non-webserver, say like your laptop of PC, the debug messages will likely just be printed to the screen (STDOUT).

    Do you have access to the cPanel error log? It's located at /usr/local/cpanel/logs/error_log. That might yield some information other than debugging from the class; some system warnings, etc.

    Need to make sure you have cURL or have fopen wrappers that can stream the request, but unless you're in a restrictive environment, fopen should be there and available by default.

    Have you tried to execute a call that just fetches information?
    try something like StatsBar::stat
    // you setup code here
    $args = array( 'display' => 'phpversion|emailaccounts') ;
    $result = $xmlapi->api2_query($account, "StatsBar", "stat", $args);
    That code should render info related to you PHP version and how many POP email accounts you have,
    // example snippet of output //
    SimpleXMLElement Object
        [apiversion] => 2
        [data] => Array
                [0] => SimpleXMLElement Object
                        [name] => phpversion
                        [_maxed] => 0
                        [count] => SimpleXMLElement Object
                        [id] => phpversion
                        [item] => PHP version
                        [langkey] => INDXPHPver
                        [max] => SimpleXMLElement Object
                                [0] =>  
                        [module] => Serverinfo
                        [percent] => 0
                        [percent10] => 0
                        [percent20] => 0
                        [percent5] => 0
                        [value] => 5.2.9
                [1] => SimpleXMLElement Object
                        [name] => emailaccounts
                        [_count] => 2
                        [_max] => unlimited
                        [_maxed] => 1
                        [count] => 2
                        [feature] => popaccts
                        [id] => emailaccounts
                        [item] => Email Accounts
                        [langkey] => INDXEmailAccounts
                        [max] => unlimited 
                        [module] => Email
                        [percent] => 0
                        [percent10] => 0
                        [percent20] => 0
                        [percent5] => 0
                        [zeroisunlimited] => 0


Share This Page