API:meteredGetVariables - Metered Billing: Get variables
Get metered billing components available for product in HostBill.
Required parameters
- product_id
- HostBill account ID
Request
GET http://url_to_your_hostbill.com/admin/api.php?api_id=API_ID&api_key=API_KEY&call=meteredGetVariables&product_id=PRODUCT_ID
<?php
include 'class.hbwrapper.php';
HBWrapper::setAPI('http://url_to_hb.com/admin/api.php','API ID','API Key');
$params = array(
'product_id'=>PRODUCT_ID
);
$return = HBWrapper::singleton()->meteredGetVariables($params);
print_r($return);
?>
<?php
$url = 'http://url_to_hb.com/admin/api.php';
$post = array(
'api_id' => API_ID,
'api_key' => API_Key,
'call' => 'meteredGetVariables',
'product_id'=>PRODUCT_ID
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$data = curl_exec($ch);
curl_close($ch);
$return = json_decode($data, true);
print_r($return);
?>
<?php
/* Use this method to access HostBill api from HostBill modules */
$api = new ApiWrapper();
$params = array(
'product_id'=>PRODUCT_ID
);
$return = $api->meteredGetVariables($params);
print_r($return);
?>
Response
{
"success": true,
"variables": [
{
"id": "4",
"product_id": "10",
"name": "Domains",
"variable_name": "powerdnspanel",
"unit_name": "domain(s)",
"cycle": "Monthly",
"scheme": "tiered",
"options": "0",
"prices": [
{
"id": "308",
"variable_id": "4",
"qty": "0",
"qty_max": "2",
"price": "5.0000"
},
{
"id": "309",
"variable_id": "4",
"qty": "2",
"qty_max": "3",
"price": "4.0000"
},
{
"id": "310",
"variable_id": "4",
"qty": "3",
"qty_max": "6",
"price": "3.0000"
},
{
"id": "311",
"variable_id": "4",
"qty": "6",
"qty_max": "0",
"price": "1.0000"
}
]
}
],
"call": "meteredGetVariables",
"server_time": 1323788816
}