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!

Cpanel XMLAPI 1.0.3 - JSON Output

Discussion in 'cPanel Developers' started by netrix37, Mar 3, 2010.

  1. netrix37

    netrix37 Member

    Joined:
    Jul 13, 2006
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    151
    I'm sure I'm missing something but if I do the following:

    Code:
    include("xmlapi.php");
    $ip = "hostname.com";
    $root_pass = "password";
    $account = "account";
    $xmlapi = new xmlapi($ip);
    $xmlapi->hash_auth("user",'MYHASHDATA');
    $xmlapi->set_output('json');
    $xmlapi->set_debug(1);
    $res = $xmlapi->api2_query($account, "Email", "listpops");
    print_r($res);
    
    I'm getting the following:

    Code:
    {"apiversion":"2","data":{"reason":"api call failed. Module name is required.","result":"0"},"type":"text"}
    
    Here is the error log:

    Code:
    [Wed Mar 03 13:24:06 2010] [error] [client IP] DATA: user=user&cpanel_xmlapi_module=Email&cpanel_xmlapi_func=listpops&cpanel_xmlapi_apiversion=2, referer: http://ip/test/
    
    Here is the version information:
    cPanel 11.25.0-R43473 - WHM 11.25.0 - X 3.9

    FWIW: This exact code (outside of set_output part) works fine and returns a simplexml object.
     
  2. cPanelDavidN

    cPanelDavidN Integration Developer

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    3
    Trophy Points:
    68
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    JSON output from api2 calls

    Howdy netrix37,

    You're following the documentation to the 'T'; I've been able to reproduce this as well with some other api2 calls.

    Like you said, it's only with JSON, XML return requests work as expected.

    I'll have to research this further to verify that the documentation is correct for JSON calls. If the docs are right, then this may be a bug.

    will get back asap; thanks for your patience!

    Regards,
    -DavidN
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. MattDees

    MattDees Well-Known Member

    Joined:
    Apr 29, 2005
    Messages:
    416
    Likes Received:
    1
    Trophy Points:
    243
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    David kindly let me know about the issue you were having. This was due to an issue in the XMLAPI Class where had "cpanel_xmlapi_*" hard coded into the api1 & api2 query functions. I have gone ahead and patched this issue in v1.0.5 and you can download it at: http://sdk.cpanel.net/lib/xmlapi/php/cp_xmlapi_php_v1.0.5.tar.gz

    Now it will use 'cpanel_jsonapi_*' for querying if the output type is 'json'.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. cPanelDavidN

    cPanelDavidN Integration Developer

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    3
    Trophy Points:
    68
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
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