Page 1 of 1

Creating additional ftp user via api

Posted: Mon Apr 06, 2015 12:05 pm
by fortxwall
Hello,

How we create additionla ftp users via api? I tried this php code but not working.

Code: Select all

<?php
// Server credentials
$vst_hostname = 'server.website.ru';
$vst_username = 'admin';
$vst_password = 'pass';
$vst_returncode = 'yes';
$vst_command = 'v-add-web-domain-ftp';


// Prepare POST query
$postvars = array(
    'user' => $vst_username,
    'password' => $vst_password,
    'returncode' => $vst_returncode,
    'cmd' => $vst_command,
    'arg1' => 'website.ru',
    'arg2' => 'newftpuser',
    'arg3' => 'newpass',
    'arg4' => '/newfolder'
);
$postdata = http_build_query($postvars);

// Send POST query via cURL
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://' . $vst_hostname . ':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);

// Check result
if($answer == 0) {
    echo "Ftp has been successfuly created\n";
} else {
    echo "Query returned error code: " .$answer. "\n";
}
?>

Re: Creating additional ftp user via api

Posted: Fri Sep 23, 2016 12:32 pm
by skurudo
API documentation and examples:
http://vestacp.com/docs/API.pdf

CLI commands list and descriptions:
http://vestacp.com/docs/CLI.txt

-> viewtopic.php?f=18&t=12610