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

free web hosting signup api

Questions regarding the API
Application Programming Interface
Post Reply
  • Print view
Advanced search
3 posts • Page 1 of 1
cameronmotes
Posts: 2
Joined: Wed May 16, 2018 6:50 pm

Os: Ubuntu 16x
Web: apache + nginx
free web hosting signup api
  • Quote

Post by cameronmotes » Fri Apr 03, 2020 2:25 am

Hello, I'm wanting to open new accounts to be created automatically for any user on my website.

Index.html

Code: Select all

<form action="action.php" method="post">
Choose Username: <input type="text" name="username"><br>
Password: <input type="password" name="password"><br>
E-mail:   <input type="text" name="email"><br>
First Name: <input type="text" name="fist_name"><br>
Last Name: <input type="text" name="last_name"><br>
<input type="submit">
</form>
In the following code under new account, I'm needing help. What would be the correct code for using the submission form to insert the details needed for creating an account.


action.php

Code: Select all

<?php

// Server credentials
$vst_hostname = 'panel.domain.com';
$vst_username = 'admin';
$vst_password = '3skTDV5AeLtjwf%b3w';
$vst_returncode = 'yes';
$vst_command = 'v-add-user';

// New Account
$username = 'demo';
$password = 'dqwd3m0p4ssw0rd';
$email = 'demo@gmail.com';
$package = '2GB';
$fist_name = 'Test';
$last_name = 'User';


// Prepare POST query
$postvars = array(
    'user' => $vst_username,
    'password' => $vst_password,
    'returncode' => $vst_returncode,
    'cmd' => $vst_command,
    'arg1' => $username,
    'arg2' => $password,
    'arg3' => $email,
    'arg4' => $package,
    'arg5' => $fist_name,
    'arg6' => $last_name
);
$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 "User account has been successfuly created\n";
} else {
    echo "Query returned error code: " .$answer. "\n";
}
?>

I believe my issue and answer resides inside this
// New Account
$username = 'demo';
$password = 'dqwd3m0p4ssw0rd';
$email = 'demo@gmail.com';
$package = '2GB';
$fist_name = 'Test';
$last_name = 'User';

These entries are hard coded, and they need to come from the submission form, I just don't know how to do this offhand.

Thanks
Last edited by cameronmotes on Fri Apr 03, 2020 2:32 am, edited 1 time in total.
Top

cameronmotes
Posts: 2
Joined: Wed May 16, 2018 6:50 pm

Os: Ubuntu 16x
Web: apache + nginx
Re: free web hosting signup api
  • Quote

Post by cameronmotes » Fri Apr 03, 2020 2:28 am

My issue is when I run the action.php it created the account fine, however using the index.html new account signup form, I can't seem to get my code right to create a new account from the form submissions.
Top

Anonymous777
Posts: 6
Joined: Sun Jul 05, 2020 2:15 am

Os: Ubuntu 18x
Web: apache + nginx
Re: free web hosting signup api
  • Quote

Post by Anonymous777 » Mon Jul 06, 2020 12:24 am

Hola, pudiste resolver tu problema?
Top


Post Reply
  • Print view

3 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