Description
Use the following API to Enable/Disable Force HTTPS for domain.
Parameters
Sample Code
Please refer following sample code for CURL and API.
curl --insecure -d "force_https=1" -d "do=1" -d "domain=example1.com" -u "user:password" -X POST "https://hostname:2003/index.php?api=json&act=domainmanage"<?php
$user = 'username';
$pass = 'password';
$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@hostname.com:2003/index.php?api=json&act=domainmanage';
$post = array(
'force_https' => 1, // Action to trigger Force HTTPS update
'do' => 1, // 1 = Enable, 0 = Disable
'domain' => 'example.com' // Domain name
);
// 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);
// The response will hold a string as per the API response method. In this case its PHP Serialize
$res = json_decode($resp, true);
// // Done ?
if(!empty($res['done'])){
print_r($res['done']['msg']);
}else{
print_r($res['error']);
}Output
Force HTTPS redirect updated for domain example.com