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 4 adding (unexisting) domain with v-add-domain

Questions regarding the API
Application Programming Interface
Post Reply
  • Print view
Advanced search
1 post • Page 1 of 1
willowmagrini
Posts: 4
Joined: Fri Aug 25, 2017 1:10 pm

Os: Ubuntu 15x
Web: apache + nginx
Error 4 adding (unexisting) domain with v-add-domain
  • Quote

Post by willowmagrini » Fri Aug 25, 2017 1:48 pm

Hello,
I´m trying to create a domain with PHP following this guide: https://vestacp.com/docs/api/#add_domain .
In my website I ´ve created a form to fill the data and send it to the script above.

I´m getting "Query returned error code: 4" even when the domain doesn't exists.
Vesta is creating Web/DNS/Mail but returning Error.
Anybody had that yet?
thanks

My function:

Code: Select all

function cria_web($user,$endereco){
 $vst_hostname = 'xxxxxxxx';
 $vst_username = 'xxxxxxxx';
 $vst_password = 'xxxxxxxx;
 $vst_returncode = 'yes';
 $vst_command = 'v-add-domain';

 // New Domain
 // Prepare POST query
 $postvars = array(
     'user' => $vst_username,
     'password' => $vst_password,
     'returncode' => $vst_returncode,
     'cmd' => $vst_command,
     'arg1' => $user,
     'arg2' => $endereco
 );
 $postdata = http_build_query($postvars);

 // Send POST query via cURL
 $postdata = http_build_query($postvars);
 $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 "Domain has been successfuly created\n";
 }
 else {
     echo "Query returned error code: " .$answer. "\n";
 }
}
Top


Post Reply
  • Print view
1 post • 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