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

Error connecting to api

Questions regarding the API
Application Programming Interface
Post Reply
  • Print view
Advanced search
2 posts • Page 1 of 1
martincr
Posts: 1
Joined: Fri Jun 19, 2020 8:57 pm

Os: Ubuntu 17x
Web: apache + nginx
Error connecting to api
  • Quote

Post by martincr » Fri Jun 19, 2020 9:04 pm

Hello, I am working on a script that works with vesta to create a database, take the example of the vesta page script, when I send the data by curl it returns a false boolean and the database registration is not done . This is my script :

$basedatos = $this->bd_clonada;
// Server credentials
$vst_hostname = 'digicloudmx.com';
$vst_username = 'digicloudmx';
$vst_password = 'mypass';
$vst_returncode = 'yes';
$vst_command = 'v-add-database';
$username = "prueba";

//$username = $basedatos;

$db_name = $basedatos;
$db_user = $this->bd_usuario;
$db_pass = $this->bd_password;

// Prepare POST query
$postvars = array(
'user' => $vst_username,
'password' => $vst_password,
'returncode' => $vst_returncode,
'cmd' => $vst_command,
'arg1' => $username,
'arg2' => $db_name,
'arg3' => $db_user,
'arg4' => $db_pass
);

$postdata = http_build_query($postvars);
var_dump($postdata); die;
// 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 "Database has been successfuly created\n";
} else {
echo "Query returned error code: " .$answer. "\n";
}

What am I doing wrong? What do I need to activate on the server? or how I know that the hostname is correct starting there.
Top

grayfolk
Support team
Posts: 1111
Joined: Tue Jul 30, 2013 10:18 pm
Contact:
Contact grayfolk
Website Facebook Skype Twitter

Os: CentOS 6x
Web: nginx + php-fpm
Re: Error connecting to api
  • Quote

Post by grayfolk » Fri Jun 19, 2020 9:46 pm

API working for admin user only.
https://github.com/serghey-rodin/vesta/ ... dex.php#L8
Top


Post Reply
  • 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