[Gandi][API] Redirection web

<?php
require_once 'XML/RPC2/Client.php';

// https://wiki.gandi.net/fr/domains/management/domain-as-website/forwarding
// http://doc.rpc.gandi.net/domain/reference.html#WebredirDescription

$api = XML_RPC2_Client::create(
    'https://rpc.gandi.net/xmlrpc/',
    array( 'prefix' => 'domain.', 'sslverify' => False  )
);

define('API_KEY', 'MY_API_KEY');

///////////////////
// Create a webdir
///////////////////

$redirec_spec = [
   'host' => 'redirection',
   'url' => 'http://my_other_domainname.info',
   'type' => 'http302',
];

$result = $api->__call( 'webredir.create', array(API_KEY,'my_domainname.fr', $redirec_spec));
print_r($result);

// http://redirection.my_domainname.fr => http://my_other_domainname.info


///////////////////
// Update a webdir
///////////////////

$redirec_spec = [
   'host' => 'newredirection',
   'url' => 'http://other_domainname.info',
   'type' => 'http302',
];


$result = $api->__call( 'webredir.update', array(API_KEY,'my_domainname.fr', 'redirection', $redirec_spec));
print_r($result);

// Replace 'redirection' by 'newredirection'
// http://newredirection.my_domainname.fr => http://other_domainname.info

?>
avril 15, 2016