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.

authentication errror

Discussion in 'cPanel Developers' started by davidvanrensbur, Sep 29, 2010.

  1. davidvanrensbur

    Joined:
    May 26, 2010
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    Im trying to get the API to work in php using simplexml. I am a reseller on cpanel.whm.
    my final issue is that i want to be able to list and change pop3 accounts from our support CRM system.

    I can use the following code to get the username of the account from the domai nname and this works...

    $url = "http://resellerusername:resellerpassword@mail.$domain:2086/xml-api/listaccts?searchtype=domain&search=$domain";
    $rss_file = file_get_contents($url);
    $xml = new SimpleXMLElement($rss_file);
    print $url;
    print_r($xml);

    $cpanelusername = ($xml->acct->user);

    print "cpanelusername: " . $cpanelusername;

    This way i can get the username.

    Then i try issue the following and it DOESNT work. which is strange.
    can i authenticate as the reseller to view a domains pop3 accounts or do i have to authenticate as that domain users and password???
    look this give me authentication errror:

    $url1 = "http://resellerusername:resellerpassword@mail.$domain:2086/xml-api/cpanel?cpanel_xmlapi_version=2&cpanel_xmlapi_module=Email&cpanel_xmlapi_func=listpopswithdisk&user=$cpanelusername";
    print $url1 . "<br>";
    $rss_file1 = file_get_contents($url1);
    $rss_file1 = file_get_contents($url1);
    $xml1 = new SimpleXMLElement($rss_file1);
    $xml1 = new SimpleXMLElement($rss_file1);
    //print $url1;
    print_r($xml1);

    am i missing something here?

    Please help ive actually been stuck for a month and if i can get over this im sure i can do all my coding....


    David.
     
  2. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
  3. davidvanrensbur

    Joined:
    May 26, 2010
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    hi,

    i find this class so complicated and dont know where to start with it.
    its not just a simple 1 line call from the api like i can test in a browser.

    can you help me list all pop3 accounts for example and then how to change a pop3 password?
     
  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
    Hi David,

    Did you get a chance and download the class? The most recent copy, found here, has an examples folder with a number of examples that should help you get started; in particular, the "api2_example.php" which performs Email::listphpswithdisk.

    If you still don't understand how the class works we can elaborate.

    Regards,
    -DavidN
     
Loading...

Share This Page