API:bulkAddProducts - Bulk add TLDs
Create multiple products/TLDS at once, using current product as template. Method takes products array as parameter, so you can add multiple products at once. Use this to add new tlds in bulk with ease. Note that this call does not check whether product already exists.
Required parameters
- products[n][copyof]
- ID of product/TLD to use as template
- products[n][name]
- Name of new product
Optional parameters
- products[n][periods][k][register]
- For tlds, set register price for {k} years for amount passed trough this argument
- products[n][periods][k][transfer]
- For tlds, set transfer price for {k} years for amount passed trough this argument
- products[n][periods][k][renew]
- For tlds, set renew price for {k} years for amount passed trough this argument
Request
GET http://url_to_your_hostbill.com/admin/api.php?token=:TOKEN&call=bulkAddProducts&products[n][copyof]=:PRODUCTS[N][COPYOF]&products[n][name]=:PRODUCTS[N][NAME]
<?php
include 'class.hbwrapper.php';
$hbw = HBWrapper::singleton();
$hbw->setAPIUrl('http://url_to_hb.com/admin/api.php');
if($hbw->logIn("adminlogin","password")) {
$return = $hbw->bulkAddProducts(array('products[n][copyof]'=>:PRODUCTS[N][COPYOF],
'products[n][name]'=>:PRODUCTS[N][NAME]));
print_r($return);
}
?>
<?php
//Use this method to access HostBill api from HostBill modules
$api = new ApiWrapper();
$return = $api->bulkAddProducts(array('products[n][copyof]'=>:PRODUCTS[N][COPYOF],
'products[n][name]'=>:PRODUCTS[N][NAME]));
print_r($return);
?>
Response
{
"success": true,
"new_products": [
"301"
],
"call": "bulkAddProducts",
"server_time": 1478712055,
"info": [
"Product .test duplicated. New product name: .test(2)",
"Product updated"
]
}