Results 1 to 14 of 14

Thread: Find API codes

  1. #1
    Member
    Join Date
    Jan 2009
    Posts
    19

    Default Find API codes

    Where can I find API codes?

    I am trying to make a script to change the contact's e-mail of a user, but this do not exist in XML API.

    I am trying to find where in cpanel installation are the codes that use the APIs.
    --
    Carlos Eduardo Tavares Terra
    System Administrator

  2. #2
    Member
    Join Date
    Dec 2008
    Posts
    153

    Default

    Well go here first
    http://forums.cpanel.net/f42/xmlapi-...ss-111897.html
    Thats what you're looking for. Just use the api1/2. The commands and the syntax for them can be found in the frontend (/usr/local/base/cpanel/frontend/x3/whatever_you_are_looking_for)

  3. #3
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,307
    cPanel/WHM Access Level

    Root Administrator

    Default

    Are you still looking for information on how to change the contact info via our APIs? If so, just let me know and I'll get you that information.

  4. #4
    Member
    Join Date
    Jan 2009
    Posts
    19

    Default

    Quote Originally Posted by jhyland87 View Post
    Well go here first
    http://forums.cpanel.net/f42/xmlapi-...ss-111897.html
    Thats what you're looking for. Just use the api1/2. The commands and the syntax for them can be found in the frontend (/usr/local/base/cpanel/frontend/x3/whatever_you_are_looking_for)
    Thanks for the answer.
    I am already using the xmlapi-php class. But there isn't any method to change contact mail there.

    I will look at frontends, but I think it is only for cpanel's functions, not WHM.

    For example, I didn't find in /usr/local/base/cpanel/frontend anything about changing a website's ip address. I will take a look better to be certain of that.
    --
    Carlos Eduardo Tavares Terra
    System Administrator

  5. #5
    Member
    Join Date
    Jan 2009
    Posts
    19

    Default

    Quote Originally Posted by cPanelDavidG View Post
    Are you still looking for information on how to change the contact info via our APIs? If so, just let me know and I'll get you that information.
    I didn' find the answer, yet. If you have the answer, please tell me.

    I will look at the frontend's folder later to find more useful functions.
    --
    Carlos Eduardo Tavares Terra
    System Administrator

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

    Root Administrator

    Default

    Quote Originally Posted by cetterra View Post
    I didn' find the answer, yet. If you have the answer, please tell me.

    I will look at the frontend's folder later to find more useful functions.
    The raw API call for this in the X3 theme is:

    [HTML]<?cp CustInfo::savecontactinfo(
    [tr]
    [td]%[/td]
    [td]%[/td]
    [/tr],name,display_value) email=$FORM{'email'},second_email=$FORM{'second_email'},notify_disk_limit=$FORM{'notify_disk_limit'},notify_bandwidth_limit=$FORM{'notify_bandwidth_limit'},notify_email_quota_limit=$FORM{'notify_email_quota_limit'} ?>
    [/HTML]

    To break this down, this is an API2 function:

    module: CustInfo
    function: savecontactinfo
    named parameter: email <- primary contact email
    named parameter: second_email <- secondary contact email
    named parameter: notify_disk_limit <- 1 to enable, 0 to disable
    named parameter: notify_bandwidth_limit <- 1 to enable, 0 to disable
    named parameter: notify_email_quota_limit <- 1 to enable, 0 to disable

    If you are coding your script in PHP 5, you may want to use Matt's PHP Class posted at: http://forums.cpanel.net/f42/xmlapi-...ss-111897.html

    Otherwise, documentation for manual implementation is posted at XmlApi < AllDocumentation/AutomationIntegration < TWiki

  7. #7
    Member
    Join Date
    Jan 2009
    Posts
    19

    Default

    I am already using the XML API PHP Class.

    I have found the following code:
    Code:
    [% IF acl.edit_account %]
        <td>[% acct.user %]&nbsp;<a href="/scripts/edituser?domain=[% acct.domain %]&user=[% acct.user %]" class="dlink"><img src="[% MagicRevision.calculate_mag
    ic_url('/change.gif') %]" border="0"></a><div class="fillerdiv">&nbsp;</div></td>
    [% ELSE %]
        <td>&nbsp;[% acct.user %]&nbsp;</td>
    [% END %]
    
    
        <td>&nbsp;<a href="mailto:[% acct.email %]">[% acct.email %]</a>&nbsp;<a href="/scripts2/changeemail?domain=[% acct.domain %]&user=[% acct.user %]" class
    ="dlink"><img src="[% MagicRevision.calculate_magic_url('/change.gif') %]" border="0"></a><div class="fillerdiv">&nbsp;</div>&nbsp;</td>
    
        <td align="center">&nbsp;[% acct.html_startdate %]&nbsp;</td>
    
    [% IF acl.all %]
        <td>[% acct.partition %]&nbsp;<a href="/scripts/rearrangeacct?domain=[% acct.user %]&user=[% acct.user %]" class="dlink"><img src="[% MagicRevision.calcu
    late_magic_url('/change.gif') %]" border="0"></a><div class="fillerdiv">&nbsp;</div></td>
    [% ELSE %]
        <td>&nbsp;[% acct.partition %]&nbsp;</td>
    [% END %]
    This code is in this file: /usr/local/cpanel/whostmgr/docroot/themes/x/templates/listaccts.tmpl

    This code is exactly what I want, but doing remotely. The '/scripts2/changeemail' is readable? What would be the API Code referent to this?

    The code you sent to me forces to change some other parameters, and didn't work in my script.

    Here is the example:
    Code:
    $dados['email'] = mymail@mail.com';
    $result = $xmlapi->api1_query('username','CustInfo','savecontactinfo',$dados);
    The return:

    Code:
    <?xml version="1.0" ?>
    <cpanelresult>
       <module>CustInfo</module>
       <func>savecontactinfo</func>
       <type>event</type>
       <source>internal</source>
       <apiversion>1</apiversion>
       <data>
           <result></result>
       </data>
    </cpanelresult>
    Last edited by cetterra; 06-10-2009 at 07:04 PM.
    --
    Carlos Eduardo Tavares Terra
    System Administrator

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

    Root Administrator

    Default

    Quote Originally Posted by cetterra View Post
    I am already using the XML API PHP Class.

    I have found the following code:
    <<Code Redacted>>

    This code is in this file: /usr/local/cpanel/whostmgr/docroot/themes/x/templates/listaccts.tmpl

    This code is exactly what I want, but doing remotely. The '/scripts2/changeemail' is readable? What would be the API Code referent to this?

    The code you sent to me forces to change some other parameters, and didn't work in my script.

    Here is the example:
    Code:
    $dados['email'] = mymail@mail.com';
    $result = $xmlapi->api1_query('username','CustInfo','savecontactinfo',$dados);
    The return:

    Code:
    <?xml version="1.0" ?>
    <cpanelresult>
       <module>CustInfo</module>
       <func>savecontactinfo</func>
       <type>event</type>
       <source>internal</source>
       <apiversion>1</apiversion>
       <data>
           <result></result>
       </data>
    </cpanelresult>
    Unlike the cPanel interface, code from the WHM interface does not always have a XML API counterpart. WHM is not based on either API1 nor API2.

    Use of /scripts2, /scripts3 ... /scripts6, /scripts (not to be confused with the /scripts directory on the file system) etc. directly is not encouraged as these can change at any time without notice. Also, these scripts don't necessarily have API counterparts at this time.

  9. #9
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,307
    cPanel/WHM Access Level

    Root Administrator

    Default

    Quote Originally Posted by cetterra View Post

    Here is the example:
    Code:
    $dados['email'] = mymail@mail.com';
    $result = $xmlapi->api1_query('username','CustInfo','savecontactinfo',$dados);
    The return:

    Code:
    <?xml version="1.0" ?>
    <cpanelresult>
       <module>CustInfo</module>
       <func>savecontactinfo</func>
       <type>event</type>
       <source>internal</source>
       <apiversion>1</apiversion>
       <data>
           <result></result>
       </data>
    </cpanelresult>
    In previous testing I've done on this function, I've noticed that all parameters for this function must be passed, not just the first parameter for this function.

  10. #10
    Member
    Join Date
    Jan 2009
    Posts
    19

    Default

    Quote Originally Posted by cPanelDavidG View Post
    In previous testing I've done on this function, I've noticed that all parameters for this function must be passed, not just the first parameter for this function.

    I've tryed with all parameters, but it didn't work too.

    Code:
    $dados['email'] = 'email@mail.com';
    $dados['secondary_email'] = '';
    $dados['notify_disk_limit'] = 1;
    $dados['notify_bandwidth_limit'] = 1;
    $dados['notify_email_quota_limit'] = 1;
    print_r($dados);
    $result = $xmlapi->api1_query('user','CustInfo','savecontactinfo',$dados);
    RAW API1 CALL:
    <cpanelaction><module>CustInfo</module><func>savecontactinfo</func><apiversion>1</apiversion><args>email@mail.com</args><args></args><args>1</args><args>1</args><args>1</args></cpanelaction>



    QUERY:
    https://server.hoster.com.br:2087/xm...panelaction%3E

    RAW XML:

    <?xml version="1.0" ?>
    <cpanelresult><module>CustInfo</module><func>savecontactinfo</func><type>event</type><source>internal</source><apiversion>1</apiversion><data><result></result></data></cpanelresult>
    --
    Carlos Eduardo Tavares Terra
    System Administrator

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

    Root Administrator

    Default

    You have double-checked the cPanel interface to ensure this API1 call failed?

    API1 isn't as good with providing success/failure messages as XML API functions are.

  12. #12
    Member
    Join Date
    Jan 2009
    Posts
    19

    Default

    Quote Originally Posted by cPanelDavidG View Post
    You have double-checked the cPanel interface to ensure this API1 call failed?

    API1 isn't as good with providing success/failure messages as XML API functions are.
    Yeah... I have checked... the contact email didn't change.
    --
    Carlos Eduardo Tavares Terra
    System Administrator

  13. #13
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,307
    cPanel/WHM Access Level

    Root Administrator

    Default

    This is an API2 function, that's why the API1 function call is failing. You are calling a function that doesn't exist in API1. Call this as an API2 function instead.

    Note, in API2, the arguments are named - unlike API1 where they are just passed sequentially.

  14. #14
    Member
    Join Date
    Jan 2009
    Posts
    19

    Default

    Quote Originally Posted by cPanelDavidG View Post
    This is an API2 function, that's why the API1 function call is failing. You are calling a function that doesn't exist in API1. Call this as an API2 function instead.

    Note, in API2, the arguments are named - unlike API1 where they are just passed sequentially.
    Uhmm.... details!!! Always the details... Now it worked!

    Thanks!
    --
    Carlos Eduardo Tavares Terra
    System Administrator

Similar Threads

  1. 'Login' Codes
    By Alfonator in forum New User Questions
    Replies: 2
    Last Post: 01-22-2006, 05:10 AM
  2. CPanel escape codes
    By Mark54321 in forum cPanel & WHM Discussions
    Replies: 5
    Last Post: 09-05-2005, 08:31 AM
  3. MySQL Error Codes Help
    By billau in forum cPanel & WHM Discussions
    Replies: 0
    Last Post: 07-30-2004, 12:34 PM