Description
Use the Add FTP Account API to add FTP user Webuzo account.
Parameters
Sample Code
curl --insecure -d "create_acc=1" -d "login=FTP_USERNAME" -d "newpass=FTP_PASSWORD" -d "conf=CONFIRM_PASSWORD" -d "ftpdomain=DOMAIN_NAME" -d "dir=FTP_DIRECTORY" -d "quota=limited" -d "quota_limit=QUOTA_LIMIT_MB" -u "USERNAME:PASSWORD" -X POST "https://hostip:2003/index.php?api=json&act=ftp_account"
<?php
$user = 'your_user';
$pass = 'your_password';
$ip = 'your_ip';
$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@'.$ip.':2003/index.php?api=json&act=ftp_account';
$post = array('create_acc' => '1', 'login' => 'FTP_USERNAME', 'newpass' => 'FTP_PASSWORD', 'conf' => 'CONFIRM_PASSWORD', 'ftpdomain' => 'DOMAIN_NAME', 'dir' => 'FTP_DIRECTORY', 'quota' => 'limited', 'quota_limit' => 'QUOTA_LIMIT_MB');
// Set the curl parameters
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if(!empty($post)){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}
// Get response from the server.
$resp = curl_exec($ch);
// The response will hold a string as per the API response method. In this case its PHP JSON
$res = json_decode($resp, true);
// Done ?
if(!empty($res['done'])){
print_r($res['done']);
// Error
}else{
print_r($res['error']);
}
<?php
include_once('/usr/local/webuzo/sdk/webuzo_sdk_v2.php');
$user = 'your_user';
$pass = 'your_password';
$host = 'your_ip';
$webuzo = new Webuzo_SDK($user, $pass, $host);
$username = 'FTP_USERNAME';
$password = 'FTP_PASSWORD';
$domain = 'DOMAIN_NAME';
$directory = 'FTP_DIRECTORY';
$quota_limit = 'QUOTA_LIMIT_MB';
$res = $webuzo->add_ftpuser($username , $password , $domain, $directory, $quota_limit);
// Done/Error
if(!empty($res['error'])){
print_r($res['error']);
}else{
print_r($res['done']);
}
?>
Output
Array ( [msg] => FTP user created.)