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.
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
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)
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.
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
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
I am already using the XML API PHP Class.
I have found the following code:
This code is in this file: /usr/local/cpanel/whostmgr/docroot/themes/x/templates/listaccts.tmplCode:[% IF acl.edit_account %] <td>[% acct.user %] <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"> </div></td> [% ELSE %] <td> [% acct.user %] </td> [% END %] <td> <a href="mailto:[% acct.email %]">[% acct.email %]</a> <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"> </div> </td> <td align="center"> [% acct.html_startdate %] </td> [% IF acl.all %] <td>[% acct.partition %] <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"> </div></td> [% ELSE %] <td> [% acct.partition %] </td> [% END %]
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:
The return:Code:$dados['email'] = mymail@mail.com'; $result = $xmlapi->api1_query('username','CustInfo','savecontactinfo',$dados);
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
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.
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
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.
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.