Skip to content
  • There are no suggestions because the search field is empty.

PHP Code Examples

We have included some code examples for connecting to the Above.com Registrar API via PHP. Be sure to replace APIKEY with your provided API key.

Note: The below code examples have been tested in PHP 5 only. For compatibility with other PHP versions, some modifications may be required.

Example 1 - Register Domains

<?php

              

              // define credentials variables

              $api_key = "APIKEY";

              

              #

              # Register the domain tennis.net using the "register" API function

              #

              

              // domain to register, seperated by commas 

              $domain = "tennis.net";

                

              // create query and URL encode values

              $query_url = "https://www.above.com/registrar/api/query.html?key=" . urlencode($api_key) . "&query=register&domain=" . urlencode($domain);

              

              // attempt connection and to put response into variable $res

              $res = file_get_contents($query_url);

              

              // if connection was unsuccessful

              if($res === false){

                

                // print error and exit

                exit("Connection error!");

                

              // if connection was successful

              } else {

              

                // parse XML results

                

                // put response in XML object $results

                $results = simplexml_load_string($res); // you could also use a regex to get data, but this way is neater

                

                // get results attributes

                $result_attr = $results->attributes();

                

                // check for error

                if($result_attr['code'] == 100) { // query was successful

                

                  // return message to show domain was registered successfully

                  echo htmlentities($domain) . " was registered successfully";

                    

                } else {     

                  

                  // return message to show domain failed to register and error message

                  echo htmlentities($domain) . " was NOT registered. Error code: " . $result_attr['code'] . " Error message: " . $results->msg;

              

                }

                

              }

            ?>

           

Example Response:

tenis.net was registered successfully

Example 2 - Transfer Domains

<?php

              

              // define credentials variables

              $api_key = "APIKEY";

              #

              # Transfer in the domains mybusiness.net using the "transfer" API function

              #

              

              // domain and epp transfer code for domain to transfer in to Above.com

              $domain = "mybusiness.net";

              $epp_code = "1w%wTlswKxX";

              // create query and URL encode values

              $query_url = "https://www.above.com/registrar/api/query.html?key="

               . urlencode($api_key) . "&query=transfer&domain=" . urlencode($domain) . "&epp_code=" . urlencode($epp_code);

              

              // attempt connection and to put response into variable $res

              $res = file_get_contents($query_url);

              

              // if connection was unsuccessful

              if($res === false){

                

                // print error and exit

                exit("Connection error!");

                

                // if connection was successful

              } else {

              

                // parse XML results

                

                // put response in XML object $results

                $results = simplexml_load_string($res); // you could also use a regex to get data, but this way is neater

                

                // get results attributes

                $result_attr = $results->attributes();

                

                // check for error

                if($result_attr['code'] == 100) { // query was successful

                

                  // return message to show domain was successfully queue for transfer

                  echo htmlentities($domain) . " was successfully queued for transfer";

                    

                } else {     

                  

                  // return message to show domain failed to transfer and error message

                  echo htmlentities($domain) . " was NOT queued for transfer. Error code: " . $result_attr['code'] . " Error message: " . $results->msg;

              

                }

                

              }

              

            ?>

           

 

Example Response:

mybusiness.net was NOT queued for transfer. Error: 904 - Domain already queued to be transferred

Copyright © 2008 - Above.com Pty Ltd a Trillion.com Company - All rights reserved.