Quick access:
[ Page content ]
[ Site menu ]
[ Other informations ]
AFNIC [ français ] Print

 
You are here : Home > Resources > Registry interface > WebServices > PHP examples
 

Sorry, this page is not available in English, but the translation is under way

As you may need the information right now, please find the French version below.

Exemples d'utilisation des webservices en PHP

En PHP, nous avons testé deux librairies : PEAR SOAP, et NuSOAP. Notez que PHP version 5 intègre directement dans sa librairie standard des fonctions SOAP. Il est possible que vous soyez amené à rajouter le module CURL de php si vous ne l'avez pas déjà : il permet d'accéder à des ressources en https, ce qui est fortement recommandé ! Nous donnons ici un exemple d'utilisation de list_domains et de status_ticket avec PEAR SOAP.

Nous donnons ici les exemples suivants de manipulation des WSDL :

Exemple d'utilisation de DomainNouveau

  • PEAR SOAP :
<html> <head><title>PHP test</title></head> <body> <?php require("/usr/share/php/PEAR/SOAP/Client.php"); // change this ! $wsdl_file = "./WSDLs/Domain.wsdl"; // change this ! $ca_file = "./ca-afnic.crt"; // change this ! $proxy = array("user" => "YOUR_LOGIN_HERE", "pass" => "YOUR_PASSWORD_HERE"); // change this ! $domain = $_REQUEST["domain"]; $wsdl = new SOAP_WSDL($wsdl_file, $proxy); $client = $wsdl->getProxy(); $client->setOpt('trace', 1); $client->setOpt('curl', CURLOPT_CAINFO, $ca_file); if ($client->city_reserved_domain($domain)) { echo "Domain [".$domain."] restricted according to names of French towns rules.<br>\n"; } // Domain availability test if domain doesn't exist if ($client->exist_domain($domain)) { echo "Domain [".$domain."] already exist !<br>\n"; } else { $result = $client->check_domain($domain); if ($result) { if ($result->free) { echo "Domain [".$domain."] is free !<br>\n"; } else { echo "Domain [".$domain."] is not available !<br>\n"; echo " ====> [CODE] : ".$result->reason."<br>\n"; echo " ====> [MESSAGE] : ".$result->message."<br>\n"; } } else { echo '<h2>Error: '.$err."</h2>"; echo "<h2>Request</h2>"; echo("<pre>" . htmlentities($soapclient->request) . "</pre>"); echo "<h2>Response</h2>"; echo("<pre>" . htmlentities($soapclient->response) . "</pre>"); } } echo "<br>\n#----------------------------------------<br><br>\n"; // All domains list... $result = $client->list_domains(); if ($result) { foreach ($result as $item) { echo $item->domain." => ".$item->anniversary."<br>\n"; } } else { echo '<h2>Error: '.$err."</h2>"; echo "<h2>Request</h2>"; echo("<pre>" . htmlentities($soapclient->request) . "</pre>"); echo "<h2>Response</h2>"; echo("<pre>" . htmlentities($soapclient->response) . "</pre>"); } ?> </body> </html>
  • NuSOAP :
<html> <head><title>PHP test</title></head> <body> <?php require( './PHP/NuSOAP/lib/nusoap.php' ); // change this ! $wsdl_file = "./WSDLs/Domain.wsdl"; // change this ! $ca_file = "./ca-afnic.crt"; // change this ! $proxy = array("user" => "YOUR_LOGIN_HERE", "pass" => "YOUR_PASSWORD_HERE"); // change this ! $domain = $_REQUEST["domain"]; $ns_client = new soapclient($wsdl_file, 'wsdl'); $ns_client->setCredentials($proxy["user"], $proxy["pass"]); $client = $ns_client->getProxy(); if ($client->city_reserved_domain($domain)) { echo "Domain [".$domain."] restricted according to names of French towns rules.<br>\n"; } // Domain availability test if domain doesn't exist if ($client->exist_domain($domain)) { echo "Domain [".$domain."] already exist !<br>\n"; } else { $result = $client->check_domain($domain); if ($result) { if ($result["free"]) { echo "Domain [".$domain."] is free !<br>\n"; } else { echo "Domain [".$domain."] is not available !<br>\n"; echo " ====> [CODE] : ".$result["reason"]."<br>\n"; echo " ====> [MESSAGE] : ".$result["message"]."<br>\n"; } } else { echo '<h2>Error: '.$err."</h2>"; echo "<h2>Request</h2>"; echo("<pre>" . $client->request . "</pre>"); echo "<h2>Response</h2>"; echo("<pre>" . $client->response . "</pre>"); } } echo "<br>\n#----------------------------------------<br><br>\n"; // All domains list... $result = $client->list_domains(); if ($result) { foreach ($result as $item) { echo $item["domain"]." => ".$item["anniversary"]."<br>\n"; } } else { echo '<h2>Error: '.$err."</h2>"; echo "<h2>Request</h2>"; echo("<pre>" . htmlentities($client->request) . "</pre>"); echo "<h2>Response</h2>"; echo("<pre>" . htmlentities($client->response) . "</pre>"); } ?> </body> </html>

On voit que l'utilisation du WSDL est là aussi très simple. Il suffit de préciser où trouver le fichier WSDL, d'indiquer quel méthode on souhaite utiliser (ici sans arguments - sinon il aurait fallu passer les arguments en paramètre, comme dans l'exemple suivant). Ensuite, on traite la réponse, en vérifiant bien si par hasard on n'a pas reçu un message d'erreur en retour. Et le tour est joué...

Exemple d'utilisation de TicketNouveau

  • PEAR SOAP :
<html> <head><title>PHP test</title></head> <body> <?php require("/usr/share/php/PEAR/SOAP/Client.php"); // change this ! $wsdl_file = "./WSDLs/Ticket.wsdl"; // change this ! $ca_file = "./ca-afnic.crt"; // change this ! $proxy = array("user" => "YOUR_LOGIN_HERE", "pass" => "YOUR_PASSWORD_HERE"); // change this ! $wsdl = new SOAP_WSDL($wsdl_file, $proxy); $client = $wsdl->getProxy(); $client->setOpt('trace', 1); $client->setOpt('curl', CURLOPT_CAINFO, $ca_file); $tick1 = $_REQUEST["tick1"]; $tick2 = $_REQUEST["tick2"]; $result = $client->current_tickets(); echo "#--------------------------------------#<br>\n"; echo "#--- CURRENT TICKET LIST ---#<br>\n"; echo "#--------------------------------------#<br>\n"; if ($result) { foreach ($result as $item) { echo "number : ".$item->number."<br>\n"; echo "domain : ".$item->domain."<br>\n"; echo "seed : ".$item->seed."<br>\n"; echo "operation : ".$item->operation."<br>\n"; echo "state : ".$item->state."<br>\n"; echo "form : ".$item->form."<br>\n"; echo "#-----------------------<br><br>\n"; } } echo "#---------------------------------------#<br>\n"; echo "#--- STATUS TICKET CHECK ---#<br>\n"; echo "#---------------------------------------#<br>\n"; $result = $client->status_ticket($tick1); if ($result) { echo "number : ".$result->number."<br>\n"; echo "domain : ".$result->domain."<br>\n"; echo "seed : ".$result->seed."<br>\n"; echo "operation : ".$result->operation."<br>\n"; echo "state : ".$result->state."<br>\n"; echo "form : ".$result->form."<br>\n"; echo "auth : ".$result->auth."<br>\n"; echo "date_creation : ".$result->creation_date."<br>\n"; echo "date_modification : ".$result->modification_date."<br>\n"; echo "remark : ".$result->remark."<br>\n"; } echo "#---------------------------------------#<br>\n"; echo "#--- TITU STATUS TICKET CHECK ---#<br>\n"; echo "#---------------------------------------#<br>\n"; $result = $client->titu_status_ticket($tick2); if ($result) { echo "number : ".$result->number."<br>\n"; echo "domain : ".$result->domain."<br>\n"; echo "seed : ".$result->seed."<br>\n"; echo "operation : ".$result->operation."<br>\n"; echo "state : ".$result->state."<br>\n"; echo "form : ".$result->form."<br>\n"; echo "auth : ".$result->auth."<br>\n"; echo "titu_nh : ".$result->titu_nh."<br>\n"; echo "titu_key : ".$result->titu_key."<br>\n"; echo "titu_mail : ".$result->titu_mail."<br>\n"; echo "date_creation : ".$result->creation_date."<br>\n"; echo "date_modification : ".$result->modification_date."<br>\n"; echo "remark : ".$result->remark."<br>\n"; } ?> </body> </html>
  • NuSOAP :
<html> <head><title>PHP test</title></head> <body> <?php require( './PHP/NuSOAP/lib/nusoap.php' ); // change this ! $wsdl_file = "./WSDLs/Ticket.wsdl"; // change this ! $ca_file = "./ca-afnic.crt"; // change this ! $proxy = array("user" => "YOUR_LOGIN_HERE", "pass" => "YOUR_PASSWORD_HERE"); // change this ! $ns_client = new soapclient($wsdl_file, 'wsdl'); $ns_client->setCredentials($proxy["user"], $proxy["pass"]); $client = $ns_client->getProxy(); $tick1 = $_REQUEST["tick1"]; $tick2 = $_REQUEST["tick2"]; $result = $client->current_tickets(); echo "#--------------------------------------#<br>\n"; echo "#--- CURRENT TICKET LIST ---#<br>\n"; echo "#--------------------------------------#<br>\n"; if ($result) { foreach ($result as $item) { echo "number : ".$item["number"]."<br>\n"; echo "domain : ".$item["domain"]."<br>\n"; echo "seed : ".$item["seed"]."<br>\n"; echo "operation : ".$item["operation"]."<br>\n"; echo "state : ".$item["state"]."<br>\n"; echo "form : ".$item["form"]."<br>\n"; echo "#-----------------------<br><br>\n"; } } echo "#---------------------------------------#<br>\n"; echo "#--- STATUS TICKET CHECK ---#<br>\n"; echo "#---------------------------------------#<br>\n"; $result = $client->status_ticket($tick1); if ($result) { echo "number : ".$result["number"]."<br>\n"; echo "domain : ".$result["domain"]."<br>\n"; echo "seed : ".$result["seed"]."<br>\n"; echo "operation : ".$result["operation"]."<br>\n"; echo "state : ".$result["state"]."<br>\n"; echo "form : ".$result["form"]."<br>\n"; echo "auth : ".$result["auth"]."<br>\n"; echo "date_creation : ".$result["creation_date"]."<br>\n"; echo "date_modification : ".$result["modification_date"]."<br>\n"; echo "remark : ".$result["remark"]."<br>\n"; } echo "#---------------------------------------#<br>\n"; echo "#--- TITU STATUS TICKET CHECK ---#<br>\n"; echo "#---------------------------------------#<br>\n"; $result = $client->titu_status_ticket($tick2); if ($result) { echo "number : ".$result["number"]."<br>\n"; echo "domain : ".$result["domain"]."<br>\n"; echo "seed : ".$result["seed"]."<br>\n"; echo "operation : ".$result["operation"]."<br>\n"; echo "state : ".$result["state"]."<br>\n"; echo "form : ".$result["form"]."<br>\n"; echo "auth : ".$result["auth"]."<br>\n"; echo "titu_nh : ".$result["titu_nh"]."<br>\n"; echo "titu_key : ".$result["titu_key"]."<br>\n"; echo "titu_mail : ".$result["titu_mail"]."<br>\n"; echo "date_creation : ".$result["creation_date"]."<br>\n"; echo "date_modification : ".$result["modification_date"]."<br>\n"; echo "remark : ".$result["remark"]."<br>\n"; } ?> </body> </html>

Exemple d'utilisation de Titulaire Nouveau

  • PEAR SOAP :
<html> <head><title>PHP test</title></head> <body> <?php require("/usr/share/php/PEAR/SOAP/Client.php"); // change this ! $wsdl_file = "./WSDLs/Titulaire.wsdl"; // change this ! $ca_file = "./ca-afnic.crt"; // change this ! $proxy = array("user" => "YOUR_LOGIN_HERE", "pass" => "YOUR_PASSWORD_HERE"); // change this ! $wsdl = new SOAP_WSDL($wsdl_file, $proxy); $client = $wsdl->getProxy(); $client->setOpt('trace', 1); $client->setOpt('curl', CURLOPT_CAINFO, $ca_file); $firstname = $_REQUEST["firstname"]; $lastname = $_REQUEST["lastname"]; $birthdate = $_REQUEST["birthdate"]; $birthplace = $_REQUEST["birthplace"]; $result = $client->holder_data($firstname, $lastname, $birthdate, $birthplace); if ($result) { foreach ($result as $item) { echo "====> ".$item->titu_key."<br>\n"; echo "====> ".$item->titu_nh."<br>\n"; echo "====> ".$item->titu_mail."<br>\n"; echo "<br>\n#-----------------------<br><br>\n"; } } ?> </body> </html>
  • NuSOAP :
<html> <head><title>PHP test</title></head> <body> <?php require( './PHP/NuSOAP/lib/nusoap.php' ); // change this ! $wsdl_file = "./WSDLs/Titulaire.wsdl"; // change this ! $ca_file = "./ca-afnic.crt"; // change this ! $proxy = array("user" => "YOUR_LOGIN_HERE", "pass" => "YOUR_PASSWORD_HERE"); // change this ! $ns_client = new soapclient($wsdl_file, 'wsdl'); $ns_client->setCredentials($proxy["user"], $proxy["pass"]); $client = $ns_client->getProxy(); $firstname = $_REQUEST["firstname"]; $lastname = $_REQUEST["lastname"]; $birthdate = $_REQUEST["birthdate"]; $birthplace = $_REQUEST["birthplace"]; $result = $client->holder_data($firstname, $lastname, $birthdate, $birthplace); if ($result) { foreach ($result as $item) { echo "====> ".$item["titu_key"]."<br>\n"; echo "====> ".$item["titu_nh"]."<br>\n"; echo "====> ".$item["titu_mail"]."<br>\n"; echo "<br>\n#-----------------------<br><br>\n"; } } ?> </body> </html>

Exemple d'utilisation de Form Nouveau

  • PEAR SOAP :
<html> <head><title>PHP test</title></head> <body> <?php require("/usr/share/php/PEAR/SOAP/Client.php"); // change this ! $wsdl_file = "./WSDLs/Form.wsdl"; // change this ! $ca_file = "./ca-afnic.crt"; // change this ! $proxy = array("user" => "YOUR_LOGIN_HERE", "pass" => "YOUR_PASSWORD_HERE"); // change this ! $wsdl = new SOAP_WSDL($wsdl_file, $proxy); $client = $wsdl->getProxy(); $client->setOpt('trace', 1); $client->setOpt('curl', CURLOPT_CAINFO, $ca_file); $result = $client->current_forms(); echo "#------------------------------------#<br>\n"; echo "#--- CURRENT FORM LIST ---#<br>\n"; echo "#------------------------------------#<br>\n"; if ($result) { foreach ($result as $item) { echo "number : ".$item->number."<br>\n"; echo "domain : ".$item->domain."<br>\n"; echo "operation : ".$item->operation."<br>\n"; echo "date : ".$item->date."<br>\n"; echo "#-----------------------<br><br>\n"; } } ?> </body> </html>
  • NuSOAP :
<html> <head><title>PHP test</title></head> <body> <?php require( './PHP/NuSOAP/lib/nusoap.php' ); // change this ! $wsdl_file = "./WSDLs/Form.wsdl"; // change this ! $ca_file = "./ca-afnic.crt"; // change this ! $proxy = array("user" => "YOUR_LOGIN_HERE", "pass" => "YOUR_PASSWORD_HERE"); // change this ! $ns_client = new soapclient($wsdl_file, 'wsdl'); $ns_client->setCredentials($proxy["user"], $proxy["pass"]); $client = $ns_client->getProxy(); $result = $client->current_forms(); echo "#------------------------------------#<br>\n"; echo "#--- CURRENT FORM LIST ---#<br>\n"; echo "#------------------------------------#<br>\n"; if ($result) { foreach ($result as $item) { echo "number : ".$item["number"]."<br>\n"; echo "domain : ".$item["domain"]."<br>\n"; echo "operation : ".$item["operation"]."<br>\n"; echo "date : ".$item["date"]."<br>\n"; echo "#-----------------------<br><br>\n"; } } ?> </body> </html>

 
 
 
My account
Access restricted to Members,
Registrars and Partners.
I log in

 

 

Last update of this page: September 22 2009
© AFNIC 2003-2010 - Contact us - Legal notice - Site map - Certificates - RSS & Atom feeds
Reporting to AFNIC unlawful domain name - Reporting unlawful web content or behaviour on www.internet-signalement.gouv.fr
 

  1. Contact us ;

  2. Presentation ;

  3. International
    cooperation ;

  4. Technology watch and R&D ;

  5. Membership ;

  6. Registrar contract ;

  1. Introduction ;

  2. The extensions ;

  3. 7 good reasons ;

  1. Make a name for yourself ;

  2. Availability ;

  3. Naming Charters ;

  4. Registrars ;

  5. After registration ;

  1. Forms ;

  2. Whois ;

  3. Whois Data Access ;

  4. ZoneCheck ;

  1. Operations news ;

  2. AFNIC's services status ;

  1. Registry interface ;

  2. Training ;

  3. FAQ ;

  4. Legal and technical references ;

  5. Registry Policy ;

  6. Other domain name
    registries ;

  7. Useful links ;

  1. News ;

  2. Calendar ;

  3. Statistics ;

  4. Industry report ;

  5. Press room ;