Gandi Wiki


Questions

HTTP redirection methods

domain_web_redir_list

Signature

array domain_web_redir_list(string session, string domain)

Description

Retrieve the web redirections of a domain.

Parameters

  • string session: the session id (returned by login)
  • string domain: the domain to retrieve the web redirections

Returns

The XML-RPC response will contain an array of web redirections (struct) or a fault describing the problem.

The returned value is a list of struct containing the following keys:

  • string type : the HTTP redirection type. Valid values include:
    • http302: Moved Temporarily / Found (rfc1945, rfc2616)
    • http301: Moved Permanently (rfc1945, rfc2616)
    • cloak: Cloaking (in a frameset)
  • string from : the FQDN redirected. The FQDN may contain a "*" wildcard.
  • string to : the URL to redirect to.

Possible faults are described in section Error Codes Format.

Sample code

  • Sample code (python)
import pprint
try:
    domain  = "example.net"
    redir_array  = proxy.domain_web_redir_list(session, domain)
    print "web redirections for '%s':" % domain
    pprint.pprint(redir_array)
except xmlrpclib.Fault, e:
    print "could not get the list of web redirections of domain '%s' because: %s" % (domain, e.faultString)
  • Sample code (php)
$domain  = "example.net";
$msg  = new xmlrpcmsg("domain_web_redir_list", array($session, new xmlrpcval($domain)));
$reply  = $proxy->send($msg);
if ($reply->faultCode()) {
    printf("could not get the list of web redirections of domain '%s' because: %s\n", $domain, $reply->faultString());
}  
else {
    printf("web redirections for '%s':\n", $domain);
    $val  = php_xmlrpc_decode($reply->value());
    print_r($val);
}
  • Sample code (perl)
my $domain  = "example.net";
my $reply  = $proxy->call("domain_web_redir_list", $session, $domain);
my $redir_array  = $reply->result();
unless (defined $redir_array) {
    printf "could not get the list of web redirections of domain '%s' because: %s\n", $domain, $reply->faultstring;
}
else {
    printf "web redirections for '%s':\n", $domain;
    print Dumper($redir_array);
}



domain_web_redir_add

Signature

int domain_web_redir_add(string session, string fqdn, string destination_url, string type)

Description

Add a web redirection to a domain. All HTTP requests to http://fqdn/ will be redirected to 'destination_url' with a HTTP redirection 'type'

Parameters

  • string session: the session id (returned by login)
  • string fqdn: the fully qualified domain name to redirect
  • string destination_url: the URL to redirect to
  • string type: the HTTP redirection type. Valid values include:
    • http302: Moved Temporarily / Found (rfc1945, rfc2616)
    • http301: Moved Permanently (rfc1945, rfc2616)
    • cloak: Cloaking (in a frameset)

Returns

The XML-RPC response will contain this operation attributed ID (int) or a fault describing the problem. Possible faults are described in section Error Codes Format.

Sample code

  • Sample code (python)
fqdn  = "example.net"
url  = "http://www.example.org/~johndoe/"
try:
    opid  = proxy.domain_web_redir_add(session, fqdn, url, "http302")
    print "adding the web redirection 'http://%s/' -> '%s' (http302) is Gandi operation #%d" % (fqdn, url, opid)
except xmlrpclib.Fault, e:
    print "could not add the web redirection 'http://%s' -> '%s' because: %s" % (fqdn, url, e.faultString)
  • Sample code (php)
$fqdn  = "example.net";
$url  = "http://www.example.org/~johndoe/";
$msg  = new xmlrpcmsg("domain_web_redir_add", array($session, new xmlrpcval($fqdn), new xmlrpcval($url), new xmlrpcval("http302")));
$reply  = $proxy->send($msg);
if ($reply->faultCode()) {
    printf("could not add the web redirection 'http://%s' -> '%s' because: %s\n", $fqdn, $url, $reply->faultString());
}  
else {
    $val  = $reply->value();
    $val  = $val->scalarval();
    printf("adding the web redirection 'http://%s' -> '%s' is Gandi operation #%d\n", $fqdn, $url, $val);
}
  • Sample code (perl)
my $fqdn  = "example.net";
my $url  = "http://www.example.org/~johndoe/";
my $reply  = $proxy->call("domain_web_redir_add", $session, $fqdn, $url, "http302");
my $opid  = $reply->result();
unless (defined $opid) {
    printf "could not add the web redirection 'http://%s' -> '%s' because: %s\n", $fqdn, $url, $reply->faultstring;
}
else {
    printf "adding the web redirection 'http://%s' -> '%s' is Gandi operation #%d\n", $fqdn, $url, $opid;
}



domain_web_redir_del

Signature

int domain_web_redir_del(string session, string fqdn)

Description

Delete the web redirection of the fully qualified domain name fqdn.

Parameters

  • string session: the session id (returned by login)
  • string fqdn: the fully qualified domain name to delete the redirection

Returns

The XML-RPC response will contain this operation attributed ID (int) or a fault describing the problem. Possible faults are described in section Error Codes Format.

Sample code

  • Sample code (python)
fqdn  = "example.net"
try:
    opid  = proxy.domain_web_redir_del(session, fqdn)
    print "deleting the web redirection 'http://%s' is Gandi operation #%d" % (fqdn, opid)
except xmlrpclib.Fault, e:
    print "could not delete the web redirection 'http://%s' because: %s" % (fqdn, e.faultString)
  • Sample code (php)
$fqdn  = "example.net";
$msg  = new xmlrpcmsg("domain_web_redir_del", array($session, new xmlrpcval($fqdn)));
$reply  = $proxy->send($msg);
if ($reply->faultCode()) {
    printf("could not delete the web redirection 'http://%s' -> '%s' because: %s\n", $fqdn, $reply->faultString());
}  
else {
    $val  = $reply->value();
    $val  = $val->scalarval();
    printf("deleting the web redirection 'http://%s -> $s' is Gandi operation #%d\n", $fqdn, $val);
}
  • Sample code (perl)
my $fqdn  = "example.net";
my $reply  = $proxy->call("domain_mail_redir_del", $session, $fqdn);
my $opid  = $reply->result();
unless (defined $opid) {
    printf "could not delete the web redirection '%s' because: %s\n", $fqdn, $reply->faultstring;
}
else {
    printf "deleting the web redirection '%s' is Gandi operation #%d\n", $fqdn, $opid;
}

Questions

Flux RSS des questions correspondant à ce filtre (Aide)

Dernière modification: le 04/12/2008 à 17:10 par Pierrick P. (Gandi)