Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Dev Section Scripting / API
  • Search

Creating additional ftp user via api

Questions regarding the API
Application Programming Interface
Locked
  • Print view
Advanced search
2 posts • Page 1 of 1
fortxwall
Posts: 1
Joined: Mon Apr 06, 2015 11:49 am

Creating additional ftp user via api

Post by fortxwall » Mon Apr 06, 2015 12:05 pm

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";
}
?>
Top

skurudo
VestaCP Team
Posts: 8099
Joined: Fri Dec 26, 2014 2:23 pm
Contact:
Contact skurudo
Website Facebook Google+ Skype
Twitter

Re: Creating additional ftp user via api

Post by skurudo » Fri Sep 23, 2016 12:32 pm

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
Top


Locked
  • Print view

2 posts • Page 1 of 1

Return to “Scripting / API”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password