Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Member
    Join Date
    Dec 2008
    Posts
    153

    Default Trouble with account summary API

    I am trying to pull an account summary from one of the accounts, this is the code I have
    PHP Code:
    <pre>
    <?php
    # cpanel12 - api2_example.php                Copyright(c) 1997-2009 cPanel, Inc.
    #                                                           All Rights Reserved.
    # copyright@cpanel.net                                         http://cpanel.net

    include("xmlapi.php.inc");

    $ip "blogforfree.net";
    $root_pass "xxxxxxx";

    $account "freeblog";

    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth("blogforf",$root_pass);

    $xmlapi->set_debug(1);
    //print $xmlapi->api2_query($account, "Ftp", "listftpwithdisk" );


    print $xmlapi->api2_query(accountsummary$account);
    ?>
    I get a php error, and access denied, as below
    PHP Code:

    Warning
    :  Missing argument 3 for xmlapi::api2_query(), called in /home/blogforf/public_html/includes/api2_example.php on line 21 and defined in /home/blogforf/public_html/includes/xmlapi.php.inc on line 112



    Warning
    :  Missing argument 4 for xmlapi::api2_query(), called in /home/blogforf/public_html/includes/api2_example.php on line 21 and defined in /home/blogforf/public_html/includes/xmlapi.php.inc on line 112



    RAW API2 CALL
    :
    freeblog



    QUERY
    :
    https://blogforfree.net:2087/xml-api/cpanel?user=accountsummary&xmlin=%3Ccpanelaction%3E%3Cmodule%3Efreeblog%3C%2Fmodule%3E%3Cfunc%3E%3C%2Ffunc%3E%3Cargs%3E%3C%2Fargs%3E%3C%2Fcpanelaction%3E

    RAW XML:


    1textAccess Denied to accountsummary.


    object(SimpleXMLElement)#2 (3) {
      
    ["apiversion"]=>
      
    string(1"1"
      
    ["type"]=>
      
    string(4"text"
      
    ["data"]=>
      
    object(SimpleXMLElement)#3 (1) {
        
    ["result"]=>
        
    string(32"Access Denied to accountsummary."
      
    }
    }
    SIMPLEXML OBJ
    Why is that?.. What am I doing wrong?

  2. #2
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by jhyland87 View Post
    Why is that?.. What am I doing wrong?
    You are attempting to call an XML API function as if it was an API2 function. I recommend calling the accountsummary XML API function as an XML API function, not as an API2 function.

  3. #3
    Member
    Join Date
    Dec 2008
    Posts
    153

    Default

    Quote Originally Posted by cPanelDavidG View Post
    You are attempting to call an XML API function as if it was an API2 function. I recommend calling the accountsummary XML API function as an XML API function, not as an API2 function.
    I looked in the documentation, I didnt see an answer to this dumb question:..

    .. whats the difference between the API and API2..

  4. #4
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by jhyland87 View Post
    I looked in the documentation, I didnt see an answer to this dumb question:..

    .. whats the difference between the API and API2..
    API1 and API2 are the APIs that the X3 theme for the cPanel interface uses to perform tasks on the cPanel/WHM server. API1 and API2 are for cPanel-related tasks.

    The XML API is an API used to interact with WHM and can be used outside of the cPanel/WHM interface. As a result, it is the basis for most billing applications that interact with cPanel/WHM since it can use some WHM functions like creating accounts etc.

    The XML API can also be used to call API1 and API2 functions from outside the cPanel interface. This allows the XML API to call functions in the cPanel interface as well as some functions of the WHM interface.

    So think of API1 and API2 as cPanel and XML API as WHM. However, if you want to call API1 and API2 from outside the cPanel interface, you can use the XML API as a bridge to do so.

  5. #5
    Member
    Join Date
    Dec 2008
    Posts
    153

    Default

    Awesome
    PHP Code:
    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth("blogforf",$root_pass);

    $xmlapi->set_debug(1);
    echo 
    '<pre>';
    print 
    $xmlapi->accoutsummary($account); 
    Works great, why isnt the BW usage listed though?

  6. #6
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by jhyland87 View Post
    Awesome
    PHP Code:
    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth("blogforf",$root_pass);

    $xmlapi->set_debug(1);
    echo 
    '<pre>';
    print 
    $xmlapi->accoutsummary($account); 
    Works great, why isnt the BW usage listed though?
    Bandwidth usage can be found in a separate function call: showbw

    To show bandwidth for a specific user, use:

    Code:
    .../xml-api/showbw?search=USERNAME&searchtype=user
    ... where USERNAME represents the username whom you want bandwidth information for.

  7. #7
    Member
    Join Date
    Dec 2008
    Posts
    153

    Default

    Quote Originally Posted by cPanelDavidG View Post
    Bandwidth usage can be found in a separate function call: showbw

    To show bandwidth for a specific user, use:

    Code:
    .../xml-api/showbw?search=USERNAME&searchtype=user
    ... where USERNAME represents the username whom you want bandwidth information for.
    I need to create this in the xmlapi.php dont I? I dont see showbw anywhere in it

    EDIT: Created it
    PHP Code:
        public function showbw($username$searchtype) {
            if (!isset(
    $username)) {
                
    error_log("showbw requires that a username is passed to it");
                return 
    0;
            }
            return 
    $this->xmlapi_query("showbw",array(search => $usernamesearchtype => $searchtype));
        } 
    Last edited by jhyland87; 05-29-2009 at 02:23 PM.

  8. #8
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by jhyland87 View Post
    I need to create this in the xmlapi.php dont I? I dont see showbw anywhere in it

    EDIT: Created it
    PHP Code:
        public function showbw($username$searchtype) {
            if (!isset(
    $username)) {
                
    error_log("showbw requires that a username is passed to it");
                return 
    0;
            }
            return 
    $this->xmlapi_query("showbw",array(search => $usernamesearchtype => $searchtype));
        } 
    Or you could have just done xmlapi_query. Note, showbw does not require a username. If no parameters are passed, the bandwidth information for all users is returned.

Similar Threads & Tags
Similar threads

  1. Trouble with removezonerecord API
    By asofrank in forum cPanel Developers
    Replies: 8
    Last Post: 05-13-2010, 02:32 AM
  2. having trouble accessing API calls
    By shadiadiph in forum cPanel Developers
    Replies: 3
    Last Post: 02-16-2010, 12:41 PM
  3. Having trouble with Transferring Multiple Account Feature
    By robstarox in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 10-11-2005, 12:16 PM
  4. Help !! Trouble with Account Transfer
    By md201 in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 07-14-2002, 07:35 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube