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.

Cant make listpopwithdisk work

Discussion in 'cPanel Developers' started by hjcg1988, Mar 16, 2011.

  1. hjcg1988

    hjcg1988 Registered

    Joined:
    Mar 16, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    I have been able to add and delete email accounts to the api using a similar code to this.
    But im not able to list the email accounts , i have been reading here in the forum and i found that it can be done with listpopswithdisk, but it doesnt display anything, anyone knows what im doing wrong?


    PHP:
    <?php
    include "xmlapi.php"

    $ip 'localhost'
    $account_pass 'xxx'// cpanel password 
    $account 'xxx';  // cpanel username 

    $email_domain "xxx";  // domain associated with the email account 

    $xmlapi = new xmlapi($ip); 
    $xmlapi->password_auth($account$account_pass); 
    $xmlapi->set_port(2083); 
    $xmlapi->set_debug(1);  // uncomment for debugging 

    $args = array( 
        
    'domain' => $email_domain
         );   

    print 
    $xmlapi->api2_query($account'Email''listpopswithdisk'$args);  
    ?>
     
  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 hjcg1988,

    When you say you're not getting anything, do you mean you're getting an empty result set similar to:
    Code:
    RESPONSE:
     <?xml version="1.0" ?>
      <cpanelresult>
        <apiversion>2</apiversion>
        <event>
          <result>1</result>
        </event>
        <func>listpopswithdisk</func>
        <module>Email</module>
      </cpanelresult>
    
    SimpleXML var_dump:
    SimpleXMLElement Object
    (
        [apiversion] => 2
        [event] => SimpleXMLElement Object
            (
                [result] => 1
            )
    
        [func] => listpopswithdisk
        [module] => Email
    )
    
    Or do you mean that you literally get nothing?

    - If you have an empty result set, I'd verify that you have the correct filter value, aka $email_domain.

    - If you get nothing, not even the debug information, then you have something wrong, most like an E_ERROR or E_WARNING in combination with your error display/reporting. Depending on your PHP settings, errors might be logged as well as errors may not be rendered. If you're not familiar with PHP's error system I'm pretty sure I have another thread in this forum that discusses it (otherwise the PHP manual is your friend ;) )

    I copied your example code and filled in the variables with my info and this script executes fine. Therefore I'm inclined to think that there's something else at play here; probably the error issue I mention above. If I had to make a wild guess about it, I'd say that you don't have SSL in you PHP binary and since you're requesting to use port 2083 (an https port), it's failing. To verify that you have SSL compiled you can look at the output of phpinfo() or if you're executing via a shell you can simple look for the module (openssl) with `php -m |grep -i ssl`

    If I place the script on a system without SSL and where error_log won't isn't my console (the debug feature sends to error_log ) AND I suppress the method invocation (which simulates not reporting errors), then I get absolutely nothing...all of which supports my guess above :)

    If that's not it, please elaborate about your output, what errors are logged, etc.

    Best Regards,
    -DavidN
     
  3. hjcg1988

    hjcg1988 Registered

    Joined:
    Mar 16, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Sorry for the late replay

    Im getting nothing just a blank page...


    I dont think is SSL as i have succesfully use addpop and deletepop to add and remove accounts, but i cant list them i always get a blank page. i have even set php 5 as default and i have the same result.Tried using listaccs same result.
    i dont know what can be wrong im using hostgator hosting , i dont know if you have heard about this problem before?
     
  4. 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
    If you're getting a completely blank page, it's likely that your script is failing at the PHP level, ie, something is causing an E_ERROR or E_WARNING (or possibly an Exception) to be thrown. When serving a PHP via Apache, which throws a fatal error, and 'display_errors' turned off (or display_errors is on, but errors are being suppressed by other means), Apache returns just the header information and an empty body in the HTTP response.

    I suggest you:
    1) first check your script for errors with `php -l myscript.php` on the command line. This runs a syntax check against a given PHP script.
    2) At the beginning of you file, use ini_set() to set error_log to someplace you have access (if you don't know where or have access to your Apache error logs)
    3) make sure that your errors are not being logged to the syslog by use ini_set() for the log_errors directive (you'll want this to be 0 (integer) because we want PHP to direct errors to the place we specified above)
    4) for debugging, you can set display_errors to 1 (integer), with ini_set(), at the beginning of the script to display the errors in the HTTP body that Apache servers. (important: this will only display non-fatal errors)...but you don't want this in a production environment...if you don't set this directive, you can aways read you error_log (that you specified above).

    This is all covered in the PHP manual concerning Error Configuration.

    Regards,
    -DavidN
     

Share This Page