buy
Admin Authentication

Description

There are 2 ways to authenticate while making API calls to Webuzo :
1) Using API Key (These can be generated from Webuzo Admin Panel -> Settings -> API Keys page)
2) Using root/reseller username and password
3) Perform Enduser Tasks with Admin/Reseller Credentials

We will take a simple List Users API call in the example below.

API Credentials

Perform Admin or Reseller Panel tasks with your root/reseller API credentials.

curl --insecure -d "apiuser=root" -d "apikey=50bjj06Ko77pJ3QvFR9BY1JpLYglezRO" -X POST "https://hostname:2005/index.php?api=json&act=users"
<?php

$apiuser = 'root';
$apikey = '50bjj06Ko77pJ3QvFR9BY1JpLYglezRO';
 
$post = array('apiuser' => $apiuser, 
              'apikey' => $apikey
);

$url = 'https://hostname.com:2005/index.php?api=json&act=users'; 

// Set the curl parameters 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

if(!empty($post)){
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}

// Get response from the server. 
$resp = curl_exec($ch);

// The response will hold a string as per the API response method. 
$res = json_decode($resp, true);
// Done ?
if(!empty($res['users'])){
    echo "<pre>";
    print_r($res['users']);
    echo "</pre>";
}else{
    print_r($res['error']);
}

Login Credentials

Perform Admin or Reseller Panel tasks with your root/reseller login credentials.

curl --insecure -u  "username:password" -X POST "https://hostname:2005/index.php?api=json&act=users"
<?php
$user = 'user_name';
$pass = 'password';
 
$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@domain.com:2005/index.php?api=json&act=users'; 

// Set the curl parameters 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

if(!empty($post)){
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}

// Get response from the server. 
$resp = curl_exec($ch);

// The response will hold a string as per the API response method. 
$res = json_decode($resp, true);
// Done ?
if(!empty($res['users'])){
    echo "<pre>";
    print_r($res['users']);
    echo "</pre>";
}else{
    print_r($res['error']);
}
<?php
include_once('/usr/local/webuzo/sdk/webuzo_sdk_v2.php');
$user = 'username';
$pass = 'password';
$host = 'hostname';

$webuzo = new Webuzo_Admin_SDK($user, $pass, $host);

$res = $webuzo->list_users();

// Done/Error
if(!empty($res['error'])){
	print_r($res['error']);
}else{
	print_r($res['users']);
}

?>

Login As Enduser

You can Perform any tasks in the Enduser Panel with your Admin/Reseller API Key or Login Credentials using the "loginAs" parameter. Lets try to list domains of the user "soft".

curl --insecure -d "apiuser=root" -d "apikey=50bjj06Ko77pJ3QvFR9BY1JpLYglezRO" -X POST "https://hostname:2003/index.php?api=json&act=domainmanage&loginAs=soft"
<?php

$apiuser = 'root';
$apikey = '50bjj06Ko77pJ3QvFR9BY1JpLYglezRO';
 
$post = array('apiuser' => $apiuser, 
              'apikey' => $apikey
);

$url = 'https://hostname.com:2003/index.php?api=json&act=domainmanage&loginAs=soft'; 

// Set the curl parameters 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

if(!empty($post)){
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}

// Get response from the server. 
$resp = curl_exec($ch);

// The response will hold a string as per the API response method. 
$res = json_decode($resp, true);
// Done ?
if(!empty($res['domains_list'])){
    echo "<pre>";
    print_r($res['domains_list']);
    echo "</pre>";
}else{
    print_r($res['error']);
}
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list