Dev License: This installation of WHMCS is running under a Development License and is not authorized to be used for production use. Please report any cases of abuse to abuse@whmcs.com

HOW TO CALL A FUNCTION USING VOIP.MS REST/JSON API Print

  • 0

The following samples show how to get all Servers Information from our database and how to select a specific Server for your display purposes.

Please Note:
- When using our REST/JSON API you need to send the Method to be used and the Required Parameters as part of the URL.
- By default the output Content-Type is "text/html".
- If you want the output Content-Type to be "application/json", add the following to your URL: &content_type=json

PHP - Using cURL GET - Sample Code

<?
$ch = curl_init();

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );

curl_setopt($ch, CURLOPT_URL,
"https://voip.ms/api/v1/rest.php?api_username=john@domain.com&api_password=password&method=getServersInfo&server_pop=1");
$result1 = curl_exec($ch);

curl_setopt($ch, CURLOPT_URL,
"https://voip.ms/api/v1/rest.php?api_username=john@domain.com&api_password=password&method=getServersInfo");
$result2 = curl_exec($ch);

curl_close($ch);

/* Convert JSON to Array */
$data1=json_decode($result1,true);
$data2=json_decode($result2,true);


echo "<pre>";

echo "
Display Specific Server
=======================
";
print_r($data1);


echo "
Display All Servers
===================
";
print_r($data2);

echo "</pre>";
?>
                            



PHP - Using cURL POST - Sample Code

<?
$postfields = array(
    'api_username'=>'john@domain.com',
    'api_password'=>'password',
    'method'=>'getServersInfo',
    'server_pop'=>'1'
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt($ch, CURLOPT_POST, true );
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_URL, "https://voip.ms/api/v1/rest.php");
$result = curl_exec($ch);
curl_close($ch);

$data=json_decode($result,true);

echo "<pre>";
print_r($data);
echo "</pre>";
?>
                            

Was this answer helpful?

« Back

Powered by WHMCompleteSolution