Softaculous


Topic : API is not working


Posted By: TopKenzo on July 20, 2020, 7:26 pm
Hello, i'm trying to integrate Virtualizor with a commercial billing software and every time i use the API, the output is "false".

Why? All data from  the API is 100% correct and when i try to use the API via direct link opening it is working.


PHP Code

 $key =  'xxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$pass 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$ip 'censored IP';

require(
$_SERVER['DOCUMENT_ROOT'].'/content/addons/Virtualizor/API/admin.php');

                
$admin = new Virtualizor_Admin_API($ip$key$pass);

                
$page 0;
                
$reslen 0;
                
//For Searching
                
$post = array();
                
$post['vpsid'] = '';
                
$post['vpsname'] = '';
                
$post['vpsip'] = '';
                
$post['vpshostname'] = '';
                
$post['vsstatus'] = '';
                
$post['vstype'] = '';
                
$post['speedcap'] = '';
                
$post['user'] = '';
                
$post['vsgid'] = '';
                
$post['vserid'] = '';
                
$post['plid'] = '';
                
$post['bpid'] = '';
                
$post['serid'] = '';
                
$post['search'] = '';

                
$output $admin->listvs($page ,$reslen ,$post);

                
print_r(json_encode($output)); // RETURNS "false" 


Posted By: virtualizor-manager on July 23, 2020, 12:41 pm | Post: 1
Hi,
try this code it should work

$key =  'xxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$pass = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$ip = 'censored IP';

require($_SERVER['DOCUMENT_ROOT'].'/content/addons/Virtualizor/API/admin.php');

                $admin = new Virtualizor_Admin_API($ip, $key, $pass);

                $output = $admin->listvs();

                print_r(json_encode($output));

//if you will just use listvs it will be fine no need to pass $post, $page, $reslen by default page is 0 and reslen i.e. the result length(number of vps to return) is 50 if you want to search vps than only pass $post
//also check if the api key and pass you provide is correct

Posted By: TopKenzo on July 23, 2020, 4:15 pm | Post: 2
Already tried this, same.

Posted By: urgido on September 25, 2021, 7:54 am | Post: 3
same issue here

Powered By AEF 1.0.8 © 2007-2008 Electron Inc.