Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Mail Server
  • Search

I can't convert php curl to axios

Questions regarding the Mail Server
Dovecot, Exim, RoundCube
Post Reply
  • Print view
Advanced search
1 post • Page 1 of 1
wavesico
Posts: 3
Joined: Tue Aug 23, 2022 6:03 pm

Os: CentOS 7x
Web: nginx + php-fpm
I can't convert php curl to axios
  • Quote

Post by wavesico » Mon Aug 29, 2022 3:13 pm

hi
I convert php curl to axios but don't work

Code: Select all

// New Account
$username = 'admin';
$domain = $vst_hostname;
$acount = ''info'
$password = 'emailpassword';

// Prepare POST query
$postvars = array(
    'user' => $vst_username,
    'password' => $vst_password,
    'returncode' => $vst_returncode,
    'cmd' => $vst_command,
    'arg1' => $username,
    'arg2' => $domain,
    'arg3' => $acount,
    'arg4' => $password
);
// 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 $vst_command.$answer." successfuly created\n";
} else {
    echo "Query returned error code: " .$answer. "\n";
}
axios

Code: Select all

axios.post('https://cordrr.tk:8083/api/', {
    user : 'admin',
    password :'YwoKFVYeNj',
    returncode : 'yes',
    cmd : 'v-add-mail-account',
    arg1 : 'admin',
    arg2 :'cordrr.tk',
    arg3 : 'ass',
    arg4 : '$password'
  })
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log('error);
  });
Error: self signed certificate
Top


Post Reply
  • Print view
1 post • Page 1 of 1

Return to “Mail Server”



  • 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