buy
Set DNS zone TTL

Description

Use the set DNS zone TTL API to set TTL (Time to live) value for all selected domains zones on your server.

The API response will be the TTL was set successfully for the selected DNS Zone(s).

Parameters

Sample Code

curl --insecure -u "user:password" -X POST "https://hostname/serverIP:2005/index.php?api=json&act=set_ttl&edit_ttl=domain1.com,domain2.com&ttl=ttl_value"
<?php
	$user = 'user_name';
	$pass = 'password';
	$host = 'serverIP/hostname';
	 
	$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@'.$host.':2005/index.php?api=json&act=set_ttl'; 

	$post = array(
		'edit_ttl' => 'domain1.com,domain2.com,',
		'ttl' => 'ttl_value',
	);

	// 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);
	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'])){
		echo "<pre>";
		print_r($res['done']['msg']);
		echo "</pre>";
	}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);

        // Domain(s) to set ttl
	$domains = 'domain1.com,domain2.com';
	$ttl = 'ttl_value';

	$res = $webuzo->set_dns_ttl($domains, $ttl);

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

Output

The TTL was set successfully for the selected DNS Zone(s)
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list