buy
Add DNS Templates

Description

Use DNS Templates API to create any specific DNS template.

Parameters

Sample code

Please refer following sample code for CURL, API and Webuzo SDK.

curl --insecure -d "create_record=1" -d "selecttype=dns_type" -d "name=prefix" -d "ttl=ttl_value" -d "address=domain_or_ip" -u "user:password" -X POST "https://hostname:2005/index.php?api=json&act=dns_template"
<?php
	$user = 'user_name';
	$pass = 'password';
	$host = 'serverIP/hostname';
	 
	$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@'.$host.':2005/index.php?api=json&act=dns_template'; 

	$post = array('create_record' => 1, 
		 'selecttype' => 'DNS_TYPE',
		'name' => 'Prefix',
		'ttl' => 14400,
		'address' => 'Address/IP',
	);

	// 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);
	
	// Check if curl failed
	if(!empty(curl_error($ch))){
		echo curl_error($ch); die();
	}
	
	// The response will hold a string as per the API response method. 
	$res = json_decode($resp, true);
	
	// Done ?
	if(!empty($res['done'])){
		print_r($res['done']['msg']);
	}else{
		print_r($res['error']);
	}
?>
<?php

	// Webuzo SDK file
	include_once('/usr/local/webuzo/sdk/webuzo_sdk_v2.php');
        $user = 'username';
	$pass = 'password';
	$host = 'serverIP/hostname';

	// Create object of Webuzo_Admin_SDK class
	$webuzo = new Webuzo_Admin_SDK($user, $pass, $host);

	$name = 'prefix';
	$type = 'DNS Type';
	$ttl = 14400;
	$address = 'Address/IP';

	$res = $webuzo->create_dns_template($name, $type, $ttl, $address);

	// Done/Error
	if(!empty($res['error'])){
		print_r($res['error']);
	}else{
		print_r($res['done']['msg']);
	}
?>

Output

DNS template added successfully
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list