| API - Solutions [message #75273] |
Wed, 23 June 2010 13:53  |
Jmunki  Messages: 14 Registered: June 2010 |
Member |
|
|
While waiting for a response to *my* problem in another post, I thought i'd share my solutions/findings for other things 
Feel free to add yours, no matter how obsure, as it may spark the thought in another user to work out their solution 
If admin want to sticky it, wiki it, edit it, take ownership of it, carry on 
If anyone knows the answers to my random thoughts/questions, answer away 
side note: $script = "domain.com" should include the http bit also, i would add it but computer says errno "You cannot use links until you have posted more than 2 messages."
Im not perfect, there might be mistakes, dont flame about lameness, offer up a solution to it 
btw, what is the correct order(not that it seems to care) of the variables:
ie action= followed by class= followed by ... etc??
All examples use PHP and follow the below layout:
<?php
//Constants :)
$script = "domain.com:7778/webcommand.php";
$params = "?login-class=client&login-name=admin&login-password=password&";
//Changes - ***this is the bit you change for the bits below***
$blurb = "action=...";
//Process & Output
$result = file_get_contents($script.$params.$blurb);
echo "$result<br>";
?>
Create a new user with plan 'free' under admin
$blurb = "action=add&class=client&name=test&v-plan_name=free___client-admin&v-type=customer&v-password=pass";
Create a new subdomain under admin: subby.domain.com
$blurb = "action=add&class=subdomain&name=subby&v-subdomain_parent=domain.com";
*TRAFFIC*
Display used traffic
$blurb = "action=getproperty&v-used-traffic_usage=";
Get provisioned traffic
$blurb = "action=getproperty&v-priv-traffic_usage=";
With the above 2 examples, if you change 'priv-traffic' to 'used-traffic', it provides the provisioned and used.
Works with v-priv-totaldisk_usage= and v-used-totaldisk_usage= to get provisioned and used diskspace also maybe others?? (btw see p.s at bottom )
*Enable and Disable Accounts*
action=getproperty&class=client&name=test&v-status=
nname=test&class=client&action=update&subaction=enable
nname=test&class=client&action=update&subaction=disable
*Shell/Bash Access*
action=getproperty&class=client&name=test&v-shell=
action=update&class=client&subaction=shell_acce ss&nname=test&v-shell=/bin/bash
action=update&class=client&subaction=shell_acce ss&nname=test&v-shell=
Command line Bits n Bobs - btw, these go into ssh, not the php above 
Enable/disable Accounts
/script/update --class=client --nname=test --subaction=enable
/script/update --class=client --nname=test --subaction=disable
Shell/Bash access
/script/update --class=client --nname=test --subaction=update --v-shell=/bin/bash
/script/update --class=client --nname=test --subaction=update --v-shell=
/script/update --class=client --nname=test --subaction=update --v-shell=/usr/bin/lxjailshell
Update client email
think the subaction is wrong, but it works 
/script/update --class=client --nname=test --subaction=information --v-contactemail='email here'
---------Below is yet to be edited :)-------------
The whole JSON thing, wrote a lil php script to split the strings up 
so below the $blurb line, add :
$result = file_get_contents($script.$params.$blurb);
echo "$result <br>";
That outputs the usual :{"message":"__success_update_successful_on_client_","return ":"success"}
Now below that if you add:
$json = $result;
$obj = json_decode($json, true);
echo "Return: ".$obj['return']."<br>";
echo "Result: ".$obj['result']."<br><br>";
foreach ($obj['result'] as $value) {
echo $value."<br>";
}
echo "<br>Message :".$obj['message']."<br>";
it will return the array and split it up.
eg: to display all domains on the account:
$script = "domain.com:7778/webcommand.php";
$params = "?login-class=client&login-name=admin&login-password=password&";
$blurb = "action=simplelist&resource=all_domain";
$result = file_get_contents($script.$params.$blurb);
echo "$result<br>";
$json = $result;
$obj = json_decode($json, true);
echo "Return: ".$obj['return']."<br>";
echo "Result: ".$obj['result']."<br><br>";
foreach ($obj['result'] as $value) {
echo $value."<br>";
}
echo "<br>Message :".$obj['message']."<br>";
Other bits n bobs ($blurb):
//returns all domains
// action=simplelist&resource=all_domain
//returns all dns temps
//action=simplelist&resource=dnstemplate
// action=simplelist&resource=
ie: action=simplelist&resource=client
//client - lists clients
//domain - lists domains
//subdomain - lists subdomains
//mysqldb-lists mysql db's
//ftpuser - lists ftp users
//mailaccount - lists all email accounts
//process - lists the process' (only the PID!??'s tho)
//component - lists compnents - does not say if active or not
//pserver - persumably server name ( comes back as localhost)
Apologies for the randomness, ill edit it later when i can think again 
J
ps. http://domain:7778/webcommand.php?login-class=client&log in-name=admin&login-password=password&output-type=js on&action=getproperty&v-used=
gives...
v-used-client_num
v-used-maindomain_num
v-used-subdomain_num"
v-used-domain_add_flag
v-used-can_change_limit_flag
v-used-can_set_disabled_flag
v-used-can_change_password_flag
v-used-document_root_flag
v-used-runstats_flag
v-used-traffic_usage
v-used-totaldisk_usage
v-used-ssl_flag
v-used-rubyfcgiprocess_num
v-used-logo_manage_flag
v-used-ftpuser_num
v-used-frontpage_flag
v-used-awstats_flag
v-used-installapp_flag
v-used-cgi_flag
v-used-php_flag
v-used-dotnet_flag
v-used-cron_minute_flag
v-used-cron_manage_flag
v-used-phpfcgi_flag
v-used-rubyrails_num
v-used-phpfcgiprocess_num
v-used-maildisk_usage
v-used-mailaccount_num
v-used-mailinglist_num
v-used-backupschedule_flag
v-used-backup_flag
v-used-dns_manage_flag
v-used-mysqldb_num
v-used-addondomain_num
v-used-webhosting_flag
they can be used in same way as the *traffic* section above (with priv and used) 
J
[Updated on: Fri, 25 June 2010 00:16] by Moderator Report message to a moderator
|
|
|
|
| Re: API - Solutions [message #76461 is a reply to message #75273] |
Wed, 18 August 2010 15:59   |
|
I just wanted to say thank you very much. This post great help newbies like me.
Hopefully someone can give a list webcomand complete and systematic.
Did the developers do not have kloxo a complete list?
I just want a little review, may be useful.
Update to the latest version, and --help will also work.
How to add a customer to admin
/script/reflect --type=add --parent-class=client --parent-name=admin --class=client --v-val=customer
How to add a reseller:
/script/reflect --type=add --parent-class=client --parent-name=admin --class=client --v-val=reseller
<?php
$script = "domain.com:7778/webcommand.php";
$params = "?login-class=client&login-name=admin&login-password=password&";
//Changes - ***this is the bit you change for the bits below***
$action = "action=...";
//Process & Output
$result = file_get_contents($script.$params.$action);
echo "$result<br>";
?>
//add client
/script/add --class=client --name=".$usr." --v-plan_name=".$plan."___client-admin --v-type=".$type." --v-contactemail=".$eml." --v-domain_name=".$dom." --v-dnstemplate_name=Main.dnst --v-password=".$pass.
or
domain.com:7778/webcommand.php?login-class=client&login-name=admin&login-password=password&output-type=json&action=add&class=client&name=test&v-password=test&v-contactemail=test@test.com&v-plan_name=100mb___client-admin&v-type=customer&v-domain_name=test.com&v-dnstemplate_name=domain.com.dnst
//delete user
/script/update --class=client --name=".$usr[1]." --action=delete
or
domain.com:7778/webcommand.php?login-class=client&login-name=admin&login-password=password&output-type=json&action=delete&class=client&name=test
//add park domain
/script/add --parent-class=domain --parent-name=maindomain.com --class=addondomain --name=parkeddomain.com&v-ttype=parked --v-mail_flag=on
or
domain.com:7778/webcommand.php?login-class=client&login-name=admin&login-password=password&output-type=json&action=add&parent-class=domain&parent-name=maindomain.com&class=addondomain&name=parkeddomain.com&v-ttype=parked&v-mail_flag=on
//add subdomain
/script/add --class=subdomain --name=subdomain --v-subdomain_parent=domain.com --v-docroot=subdomain
or
domain.com:7778/webcommand.php?login-class=client&login-name=admin&login-password=password&output-type=json&action=add&class=subdomain&name=subdomain&v-subdomain_parent=domain.com&v-docroot=subdomain
//add domain
/script/add --class=domain --name=testdomain4.com --v-docroot=testdomain.com/curent/public --v-password=xyz --v-dnstemplate_name=default.dnst
or
domain.com:7778/webcommand.php?login-class=client&login-name=admin&login-password=test123&output-type=json&action=add&class=domain&name=testdomain.com&v-docroot=domain.com&v-password=password&v-dnstemplate_name=domain.com.dnst
//delete domain
/script/update --class=domain --name=".$domain." --action=delete
or
domain.com:7778/webcommand.php?login-class=client&login-name=admin&login-password=test123&output-type=json&action=delete&class=domain&name=testdomain.com
//Modify DNS Record
/script/add --parent-class=dns --parent-name=domain.com --class=dns_record_a -v-ttype=a --v-hostname=subdomain --v-param=192.168.1.1
/script/add --parent-class=dns --parent-name=domain.com --class=dns_record_a -v-ttype=cname --v-hostname=subdomain --v-param=cnamesub
/script/add --parent-class=dns --parent-name=domain.com --class=dns_record_a -v-ttype=ns --v-param=ns.lxlabs.net
/script/update --class=dns --name=domain.com --subaction=general --v-ttl=newttl
[Updated on: Wed, 18 August 2010 16:14] Report message to a moderator
|
|
|
| Re: API - Solutions [message #81578 is a reply to message #75273] |
Tue, 29 March 2011 08:27   |
|
In WHMCS, when I click on CREATE under client>Products/Services, it creates the client, but not the domain itself... And WHMCS reports this msg: Module Command Error __error_could_not_connect_to_db . I check Kloxo, I see the client but Domain = 0, I have NO idea how to edit the api etc. I am not that clued up. Can u help or advise me pls.
|
|
|
| Re: API - Solutions [message #81579 is a reply to message #81578] |
Tue, 29 March 2011 08:48   |
|
Here is a copy of the tail logs from putty
07:45 Mar/29/2011: array (
'login-class' => 'client',
'login-name' => 'admin',
'login-password' => 'xxxxxxx',
'output-type' => 'json',
'action' => 'simplelist',
'resource' => 'resourceplan',
)
07:45 Mar/29/2011: __success_simplelist
07:45 Mar/29/2011: array (
'login-class' => 'client',
'login-name' => 'admin',
'login-password' => 'xxxxxxx',
'output-type' => 'json',
'action' => 'add',
'class' => 'client',
'name' => 'peitshop',
'v-password' => 'sMg22C2x4z',
'v-plan_name' => '200mb___client-admin',
'v-type' => 'customer',
'v-contactemail' => 'info@itstore.co.za',
'v-send_welcome_f' => 'off',
'v-domain_name' => 'peitshop.za.net',
'v-dnstemplate_name' => 'DNS_support_template.dnst',
'v-websyncserver' => 'localhost',
'v-mmailsyncserver' => 'localhost',
'v-mysqldbsyncserver' => 'localhost',
'v-dnssyncserver_list' => 'localhost',
)
07:45 Mar/29/2011: __error_could_not_connect_to_db
I've "xxxxxx" the password for security reasons....
Regards
Michael
|
|
|
|