Page 1 of 1
Admin API Problems
Posted: Fri Oct 18, 2013 1:22 pm
by Graham
skid wrote:Admin API 100% ready and available via http. Use POST as request method. Here are some useful examples
Code: Select all
# Crete new user account "demo"
https://server-ip:8083/api/?&user=admin&password=currentpwd&cmd=v-add-domain&arg1=demo&arg2=d3m0p4ssw0rd&[email protected]
# Add domain demo.vestacp.com
https://server-ip:8083/api/?&user=admin&password=currentpwd&cmd=v-add-domain&arg1=demo&arg2=demo.vestacp.com
Hi All,
When I try to do anything via a post request to the API I'm getting a pretty empty HTTP 200 response back from the server.
Just tried this one:
Code: Select all
https://x.x.x.x:8083/api/?&user=admin&password=makeyuppey&cmd=v-add-domain&arg1=graham&arg2=wpcp.graham.pw&arg3=146.185.129.249
Anybody got this working yet or have any suggestions?
Thanks
Re: Admin API Problems
Posted: Fri Oct 18, 2013 3:14 pm
by skid
Try to play with following code
Here is an example for user listing which sho
Code: Select all
<?php
// Server credentials
$server = 'your-server.vestacp.com';
$user = 'admin';
$password = '1 slice of pizza!';
// Prepare variables
$postvars = array(
'user' => $user,
'password' => $password,
'cmd' => 'v-list-users',
'arg1' => 'json'
);
$postdata = http_build_query($postvars);
// Get current status
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://' . $server . ':8083/api/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$answer = curl_exec($curl);
$results = json_decode($answer, true);
print_r($results);
?>
If you want to parse result instead of output then add returncode=yes to your request
Code: Select all
<?php
// Server credentials
$server = 'your-server.vestacp.com';
$user = 'admin';
$password = '1 slice of pizza!';
// Prepare variables
$postvars = array(
'user' => $user,
'password' => $password,
'cmd' => 'v-delete-user',
'arg1' => 'admin',
'returncode' => 'yes'
);
$postdata = http_build_query($postvars);
// Get current status
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://' . $server . ':8083/api/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
$answer = curl_exec($curl);
if ($answer != 0) {
echo "Command failed";
} else {
echo "Command succeed";
}
?>
Re: Admin API Problems
Posted: Fri Oct 18, 2013 3:58 pm
by Graham
Perfect, thanks skid.
Re: Admin API Problems
Posted: Tue Feb 11, 2014 11:34 pm
by sirpros
hello,
I tried using the API and I've been able to successfully get two commands to work.
Please what are the other possible commands and how are their postvars know ?
I'll like to know if I can do email creation, creation of ftp account, and setting of MX records from the API.
Thanks in advance.
Re: Admin API Problems
Posted: Tue Feb 11, 2014 11:48 pm
by Graham
sirpros wrote:hello,
I tried using the API and I've been able to successfully get two commands to work.
Please what are the other possible commands and how are their postvars know ?
I'll like to know if I can do email creation, creation of ftp account, and setting of MX records from the API.
Thanks in advance.
They're all shown here, you can open each one to check the params
https://github.com/serghey-rodin/vesta/tree/master/bin
Re: Admin API Problems
Posted: Wed Feb 12, 2014 9:06 am
by sirpros
Thanks a lot.
Sergey is the man....always been.