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.

having trouble accessing API calls

Discussion in 'cPanel Developers' started by shadiadiph, Jan 29, 2010.

  1. shadiadiph

    shadiadiph Registered

    Joined:
    Jan 29, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Hi i have a reseller account with another company and they have cpsess enabled all my scripts i wrote using fopen used to work but they turned fopen off I have been trying to use your addpop but keep getting access denied result what can be going wrong?

    Code:
    <?php
    include("xmlapi.php.inc");
    
    $ip = "whr4.whrcisp4.com";
    $root_pass = "mycpanelpassword";
    
    $account = "mycpanelusername";
    $email_user = "johnsmith";
    $email_password = "FlubbeR678";
    $email_domain = "buyandsell123.com";
    
    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth("root",$root_pass);
    
    $xmlapi->set_debug(1);
    print $xmlapi->api1_query($account, "Email", "addpop", array($email_user, $email_password, $email_domain) );
    ?>
    
    returns the error

    Code:
    RAW API1 CALL: Emailaddpop1johnsmithFlubbeR678buyandsell123.com QUERY: https://whr4.whrcisp4.com:2083/xml-api/cpanel?user=mycpanelusername&xmlin=%3Ccpanelaction%3E%3Cmodule%3EEmail%3C%2Fmodule%3E%3Cfunc%3Eaddpop%3C%2Ffunc%3E%3Capiversion%3E1%3C%2Fapiversion%3E%3Cargs%3Ejohnsmith%3C%2Fargs%3E%3Cargs%3EFlubbeR678%3C%2Fargs%3E%3Cargs%3Ebuyandsell123.com%3C%2Fargs%3E%3C%2Fcpanelaction%3E RAW XML: 0 Access denied object(SimpleXMLElement)#2 (1) { ["data"]=> object(SimpleXMLElement)#3 (2) { ["result"]=> string(1) "0" ["reason"]=> string(13) "Access denied" } } SIMPLEXML OBJ: 
    [code]
    
    just to let you know where it says mycpanelusername uses my real username
    
    Any help would be most appreciated
     
  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
    The interesting thing here is that if there's a token error it will state "token denied" not "access denied" so I do not think that cpsess is the issue. However I am noticing:

    $xmlapi->password_auth("root",$root_pass);

    since you said you have a reseller account, you may want to adjust this to the correct user.
     
  3. shadiadiph

    shadiadiph Registered

    Joined:
    Jan 29, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    tried changing the user and am getting a different error

    Hi Matt thanks for the reply i tried your suggestion changing root to my username but i am now getting a different error

    Code:
    include("xmlapi.php.inc");
    
    $ip = "whr4.whrcisp4.com";
    $root_pass = "mycpanelpassword";
    
    $account = "mycpanelusername";
    $email_user = "johnsmith";
    $email_password = "FlubbeR678";
    $email_domain = "buyandsell123.com";
    
    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth("mycpanelusername",$root_pass);
    
    $xmlapi->set_debug(1);
    print $xmlapi->api1_query($account, "Email", "addpop", array($email_user, $email_password, $email_domain) );
    
    now it returns
    Code:
    RAW API1 CALL: Emailaddpop1johnsmithFlubbeR678@buyandsell123.com QUERY: https://whr4.whrcisp4.com:2083/xml-api/cpanel?user=buyandse&xmlin=%3Ccpanelaction%3E%3Cmodule%3EEmail%3C%2Fmodule%3E%3Cfunc%3Eaddpop%3C%2Ffunc%3E%3Capiversion%3E1%3C%2Fapiversion%3E%3Cargs%3Ejohnsmith%3C%2Fargs%3E%3Cargs%3EFlubbeR678%3C%2Fargs%3E%3Cargs%3E%40buyandsell123.com%3C%2Fargs%3E%3C%2Fcpanelaction%3E RAW XML: Emailaddpopeventinternal1Sorry, the given email address is invalid. 1 object(SimpleXMLElement)#2 (7) { ["module"]=> string(5) "Email" ["func"]=> string(6) "addpop" ["type"]=> string(5) "event" ["source"]=> string(8) "internal" ["apiversion"]=> string(1) "1" ["data"]=> object(SimpleXMLElement)#3 (1) { ["result"]=> string(43) "Sorry, the given email address is invalid. " } ["event"]=> object(SimpleXMLElement)#4 (1) { ["result"]=> string(1) "1" } } SIMPLEXML OBJ: 
    [code]
    
    seem likes its not locking me out now but i don't see how the email address is invalid??
     
  4. 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
    you're missing quota in your query.

    try:

    PHP:
    print $xmlapi->api1_query($account"Email""addpop", array($email_user$email_password0,$email_domain) );
    ?>
     

Share This Page