Introduction
This document provides an overview of how to use the Free Registry for ENUM and Domains (FRED) API for managing domain names. The API allows users to perform various domain-related operations such as registering, transferring, renewing, and managing DNS and contact information.
Prerequisites
Before using the FRED API, ensure you have the following:
- FRED API Credentials: Username and password for authentication.
- EPP Class Library: A PHP library for handling EPP (Extensible Provisioning Protocol) requests.
- Configuration File: A
config.phpfile containing your API credentials and settings.
Configuration
The configuration function fred_getConfigArray returns an array of configuration settings required for connecting to the FRED API.
function fred_getConfigArray() {
$configarray = array(
“Username” => array(“Type” => “text”, “Size” => “20”, “Description” => “Enter your username here”),
“Password” => array(“Type” => “password”, “Size” => “20”, “Description” => “Enter your password here”),
“TestMode” => array(“Type” => “yesno”),
);
return $configarray;
}
Nameserver Management
Get Nameservers
The fred_GetNameservers function retrieves the nameservers for a given domain.
function fred_GetNameservers($params) {
$username = $params[“Username”];
$password = $params[“Password”];
$testmode = $params[“TestMode”];
$tld = $params[“tld”];
$sld = $params[“sld”];
try {
$epp = new myfredEPP();
$epp->Login();
$epp->Process();
$xml = $epp->eppDomainInfo($sld . “.” . $tld, $params[“transfersecret”]);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “EPP Domain Information”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
$nsset = $doc->getElementsByTagName(“nsset”)->item(0)->nodeValue;
$hostarr = $epp->eppHostInfo($nsset);
$hostinfo = $epp->request($hostarr);
$doc = new DOMDocument();
$doc->loadXML($hostinfo);
$ns = $doc->getElementsByTagName(‘name’);
$i = 1;
$values = array();
foreach ($ns as $nn) {
$values[“ns” . $i] = $nn->nodeValue;
++$i;
}
} catch (Exception $e) {
$values[“error”] = $e->getMessage();
return $values;
}
$xml = $epp->eppLogout();
$response = $epp->request($xml);
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
return $values;
}
Save Nameservers
The fred_SaveNameservers function updates the nameservers for a given domain.
function fred_SaveNameservers($params) {
$username = $params[“Username”];
$password = $params[“Password”];
$testmode = $params[“TestMode”];
$tld = $params[“tld”];
$sld = $params[“sld”];
$domain = “$sld.$tld”;
try {
$epp = new myfredEPP();
$epp->Login();
$epp->Process();
$xml = $epp->eppDomainInfo($sld . “.” . $tld, $params[“transfersecret”]);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Domain Information”, $xml, $response);
}
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
$RegistrantContactID = $doc->getElementsByTagName(“registrant”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
$hostID = $epp->eppContactId(16, “”, “”, 1);
$xml = $epp->eppHostCheck($hostID);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “EPP Host Check”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
$nameservers = array();
if (!empty($params[“ns1”])) array_push($nameservers, $params[“ns1”]);
if (!empty($params[“ns2”])) array_push($nameservers, $params[“ns2”]);
if (!empty($params[“ns3”])) array_push($nameservers, $params[“ns3”]);
if (!empty($params[“ns4”])) array_push($nameservers, $params[“ns4”]);
if (!empty($params[“ns5”])) array_push($nameservers, $params[“ns5”]);
$xml = $epp->eppHostCreate($hostID, $nameservers, $RegistrantContactID);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “EPP Host Create”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
$xml = $epp->eppDomainNSSETUpdate($domain, $hostID);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “EPP Domain Update”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
} catch (Exception $e) {
$values[“error”] = $e->getMessage();
return $values;
}
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
return $values;
}
Domain Lock Management
Get Registrar Lock
The fred_GetRegistrarLock function retrieves the lock status of a domain.
function fred_GetRegistrarLock($params) {
$username = $params[“Username”];
$password = $params[“Password”];
$testmode = $params[“TestMode”];
$tld = $params[“tld”];
$sld = $params[“sld”];
if ($lock == “1”) {
$lockstatus = “locked”;
} else {
$lockstatus = “unlocked”;
}
return $lockstatus;
}
Save Registrar Lock
The fred_SaveRegistrarLock function updates the lock status of a domain.
function fred_SaveRegistrarLock($params) {
$username = $params[“Username”];
$password = $params[“Password”];
$testmode = $params[“TestMode”];
$tld = $params[“tld”];
$sld = $params[“sld”];
if ($params[“lockenabled”]) {
$lockstatus = “locked”;
} else {
$lockstatus = “unlocked”;
}
$values[“error”] = $Enom->Values[“Err1”];
return $values;
}
Email Forwarding ManagementGet Email Forwarding
The fred_GetEmailForwarding function retrieves email forwarding settings.
function fred_GetEmailForwarding($params) {
$username = $params[“Username”];
$password = $params[“Password”];
$testmode = $params[“TestMode”];
$tld = $params[“tld”];
$sld = $params[“sld”];
foreach ($result as $value) {
$values[$counter][“prefix”] = $value[“prefix”];
$values[$counter][“forwardto”] = $value[“forwardto”];
}
return $values;
}
Save Email Forwarding
The fred_SaveEmailForwarding function updates email forwarding settings.
function fred_SaveEmailForwarding($params) {
$username = $params[“Username”];
$password = $params[“Password”];
$testmode = $params[“TestMode”];
$tld = $params[“tld”];
$sld = $params[“sld”];
foreach ($params[“prefix”] as $key => $value) {
$forwardarray[$key][“prefix”] = $params[“prefix”][$key];
$forwardarray[$key][“forwardto”] = $params[“forwardto”][$key];
}
}
DNS Management
Get DNS Records
The fred_GetDNS function retrieves DNS records for a domain.
function fred_GetDNS($params) {
$username = $params[“Username”];
$password = $params[“Password”];
$testmode = $params[“TestMode”];
$tld = $params[“tld”];
$sld = $params[“sld”];
$hostrecords = array();
$hostrecords[] = array(“hostname” => “ns1”, “type” => “A”, “address” => “192.168.0.1”);
$hostrecords[] = array(“hostname” => “ns2”, “type” => “A”, “address” => “192.168.0.2”);
return $hostrecords;
}
Save DNS Records
The fred_SaveDNS function updates DNS records for a domain.
function fred_SaveDNS($params) {
$username = $params[“Username”];
$password = $params[“Password”];
$testmode = $params[“TestMode”];
$tld = $params[“tld”];
$sld = $params[“sld”];
foreach ($params[“dnsrecords”] as $key => $values) {
$hostname = $values[“hostname”];
$type = $values[“type”];
$address = $values[“address”];
}
$values[“error”] = $Enom->Values[“Err1”];
return $values;
}
Domain Registration
Register Domain
The fred_RegisterDomain function registers a new domain.
function fred_RegisterDomain($params) {
$username = $params[“Username”];
$password = $params[“Password”];
$testmode = $params[“TestMode”];
$tld = $params[“tld”];
$sld = $params[“sld”];
$regperiod = $params[“regperiod”];
$ns[0] = $params[“ns1”];
$ns[1] = $params[“ns2”];
$ns[2] = $params[“ns3”];
$ns[3] = $params[“ns4”];
try {
$epp = new myfredEPP();
$epp->Login();
$epp->Process();
$xml = $epp->eppDomainCheck($params[“original”][“sld”] . “.” . $params[“original”][“tld”]);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “EPP Domain Check – Registration”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $registry->eppLogout();
$response = $client->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
$domainAvailable = $doc->getElementsByTagName(“name”)->item(0)->getAttribute(“avail”);
if ($domainAvailable != “0” && $domainAvailable != “false”) {
$registrantContactID = $epp->eppContactId(16, “”, “”, 1);
$xml = $epp->eppContactCheck($registrantContactID);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “EPP Contact Check”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
$contactAvailable = $doc->getElementsByTagName(“id”)->item(0)->getAttribute(“avail”);
if ($contactAvailable != “0” && $contactAvailable != “false”) {
$postalInfo = array(“loc” => array(
“name” => $params[“original”][“firstname”] . ” ” . $params[“original”][“lastname”],
“org” => $params[“original”][“companyname”],
“street” => array(0 => $params[“original”][“address1”], 1 => $params[“original”][“address2”], 2 => “”),
“city” => $params[“original”][“city”],
“sp” => $params[“original”][“state”],
“pc” => $params[“postcode”],
“cc” => strtoupper($params[“country”])
));
$xml = $epp->eppContactCreate($registrantContactID, $postalInfo, $params[“phonenumberformatted”], “”, $params[“email”], $epp->eppKey(), “”, “”, “”, “”);
logModuleCall(“fredEPP”, “EPP Contact Create”, $xml, “”);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “EPP Contact Create”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
}
$adminContactID = $epp->eppContactId(16, “”, “”, 1);
$xml = $epp->eppContactCheck($adminContactID);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “EPP Admin Contact Check”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
$contactAvailable = $doc->getElementsByTagName(“id”)->item(0)->getAttribute(“avail”);
if ($contactAvailable != “0” && $contactAvailable != “false”) {
$postalInfo = array(“” => array(
“name” => $params[“original”][“firstname”] . ” ” . $params[“original”][“lastname”],
“org” => $params[“original”][“companyname”],
“street” => array(0 => $params[“original”][“address1”], 1 => $params[“original”][“address2”], 2 => “”),
“city” => $params[“original”][“city”],
“sp” => $params[“original”][“state”],
“pc” => $params[“postcode”],
“cc” => strtoupper($params[“country”])
));
$xml = $epp->eppContactCreate($adminContactID, $postalInfo, $params[“phonenumberformatted”], “”, $params[“email”], $epp->eppKey(), “”, “”, “”, “”);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “Admin EPP Contact Create”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
$adminContact[0] = $adminContactID;
}
$techContact = “”;
$billingContact = “”;
$hostID = $epp->eppContactId(16, “”, “”, 1);
$xml = $epp->eppHostCheck($hostID);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “EPP Host Check”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
$hostAvailable = $doc->getElementsByTagName(“id”)->item(0)->getAttribute(“avail”);
if ($hostAvailable != “0” && $hostAvailable != “false”) {
$nameservers = array();
if (!empty($params[“ns1”])) array_push($nameservers, $params[“ns1”]);
if (!empty($params[“ns2”])) array_push($nameservers, $params[“ns2”]);
if (!empty($params[“ns3”])) array_push($nameservers, $params[“ns3”]);
if (!empty($params[“ns4”])) array_push($nameservers, $params[“ns4”]);
if (!empty($params[“ns5”])) array_push($nameservers, $params[“ns5”]);
$xml = $epp->eppHostCreate($hostID, $nameservers, $adminContactID);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “EPP Host Create”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
}
$xml = $epp->eppDomainCreate($params[“original”][“sld”] . “.” . $params[“original”][“tld”], “y”, $params[“regperiod”], $hostID, $registrantContactID, $adminContactID, $techContact, $billingContact);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “EPP Domain Create”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
$xml = $epp->eppDomainInfo($params[“original”][“sld”] . “.” . $params[“original”][“tld”], $params[“transfersecret”]);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “EPP Domain Information – Create”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
$domain = $params[“original”][“sld”] . “.” . $params[“original”][“tld”];
$regdate = gmdate(“Y-m-d”, strtotime($doc->getElementsByTagName(“crDate”)->item(0)->nodeValue));
$expdate = gmdate(“Y-m-d”, strtotime($doc->getElementsByTagName(“exDate”)->item(0)->nodeValue));
$query = “UPDATE tbldomains SET registrationdate='” . $regdate . “‘, expirydate='” . $expdate . “‘, status=’Active’ WHERE domain='” . $domain . “‘”;
mysql_query($query);
}
} catch (Exception $e) {
$values[“error”] = $e->getMessage();
return $values;
}
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
return $values;
}
Domain Transfer
Transfer Domain
The fred_TransferDomain function transfers a domain to another registrar.
function fred_TransferDomain($params) {
$username = $params[“Username”];
$password = $params[“Password”];
$testmode = $params[“TestMode”];
$tld = $params[“tld”];
$sld = $params[“sld”];
$regperiod = $params[“regperiod”];
$transfersecret = $params[“transfersecret”];
try {
$epp = new myfredEPP();
$epp->Login();
$epp->Process();
$xml = $epp->eppDomainTransfer($params[“original”][“sld”] . “.” . $params[“original”][“tld”], “y”, $params[“regperiod”], $params[“transfersecret”]);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “EPP Domain Transfer”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000” && $messagecode != “1001”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
$domain = $params[“original”][“sld”] . “.” . $params[“original”][“tld”];
$query = “UPDATE tbldomains SET status=’Pending Transfer’ WHERE domain='” . $domain . “‘”;
mysql_query($query);
} catch (Exception $e) {
$values[“error”] = $e->getMessage();
return $values;
}
$values[“error”] = $error;
return $values;
}
Domain Renewal
Renew Domain
The fred_RenewDomain function renews a domain for a specified period.
function fred_RenewDomain($params) {
$username = $params[“Username”];
$password = $params[“Password”];
$testmode = $params[“TestMode”];
$tld = $params[“tld”];
$sld = $params[“sld”];
$regperiod = $params[“regperiod”];
try {
$epp = new myfredEPP();
$epp->Login();
$epp->Process();
$xml = $epp->eppDomainInfo($params[“sld”] . “.” . $params[“tld”], $params[“transfersecret”]);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Domain Information”, $xml, $response);
}
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
list($curExpDate) = explode(“T”, $doc->getElementsByTagName(“exDate”)->item(0)->nodeValue);
$xml = $epp->eppDomainRenew($params[“sld”] . “.” . $params[“tld”], $curExpDate, “y”, $params[“regperiod”]);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “EPP Domain Renew”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
} catch (Exception $e) {
$values[“error”] = $e->getMessage();
return $values;
}
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
return $values;
}
Contact Management
Get Contact Details
The fred_GetContactDetails function retrieves the contact details for a domain.
function fred_GetContactDetails($params) {
$sld = $params[“sld”];
$tld = $params[“tld”];
$domain = “$sld.$tld”;
try {
$epp = new myfredEPP();
$epp->Login();
$epp->Process();
$xml = $epp->eppDomainInfo($params[“sld”] . “.” . $params[“tld”], $params[“transfersecret”]);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “EPP Domain Information – Contact”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
$RegistrantContactID = $doc->getElementsByTagName(“registrant”)->item(0)->nodeValue;
$AdminContactID = $doc->getElementsByTagName(“admin”)->item(0)->nodeValue;
if ($RegistrantContactID != “”) {
$xml = $epp->eppContactInfo($RegistrantContactID);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “EPP Registrant Contact Information”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($registrydata[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
$values[“Registrant”][“Name”] = $doc->getElementsByTagName(“name”)->item(0)->nodeValue;
$values[“Registrant”][“Company Name”] = $doc->getElementsByTagName(“org”)->item(0)->nodeValue;
$values[“Registrant”][“Email Address”] = $doc->getElementsByTagName(“email”)->item(0)->nodeValue;
$values[“Registrant”][“Address 1”] = $doc->getElementsByTagName(“street”)->item(0)->nodeValue;
$values[“Registrant”][“City”] = $doc->getElementsByTagName(“city”)->item(0)->nodeValue;
$values[“Registrant”][“State”] = $doc->getElementsByTagName(“sp”)->item(0)->nodeValue;
$values[“Registrant”][“Zip”] = $doc->getElementsByTagName(“pc”)->item(0)->nodeValue;
$values[“Registrant”][“Country”] = $doc->getElementsByTagName(“cc”)->item(0)->nodeValue;
$values[“Registrant”][“Phone Number”] = $doc->getElementsByTagName(“voice”)->item(0)->nodeValue;
}
if ($AdminContactID != “”) {
$xml = $epp->eppContactInfo($AdminContactID);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “EPP Admin Contact Information”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
$values[“Admin”][“Name”] = $doc->getElementsByTagName(“name”)->item(0)->nodeValue;
$values[“Admin”][“Email Address”] = $doc->getElementsByTagName(“email”)->item(0)->nodeValue;
$values[“Admin”][“Address 1”] = $doc->getElementsByTagName(“street”)->item(0)->nodeValue;
$values[“Admin”][“Address 2”] = $doc->getElementsByTagName(“street”)->item(1)->nodeValue;
$values[“Admin”][“Address 3”] = $doc->getElementsByTagName(“street”)->item(2)->nodeValue;
$values[“Admin”][“City”] = $doc->getElementsByTagName(“city”)->item(0)->nodeValue;
$values[“Admin”][“State”] = $doc->getElementsByTagName(“sp”)->item(0)->nodeValue;
$values[“Admin”][“Zip”] = $doc->getElementsByTagName(“pc”)->item(0)->nodeValue;
$values[“Admin”][“Country”] = $doc->getElementsByTagName(“cc”)->item(0)->nodeValue;
$values[“Admin”][“Phone Number”] = $doc->getElementsByTagName(“voice”)->item(0)->nodeValue;
}
} catch (Exception $e) {
$values[“error”] = $e->getMessage();
return $values;
}
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
return $values;
}
Save Contact Details
The fred_SaveContactDetails function updates the contact details for a domain.
function fred_SaveContactDetails($params) {
$username = $params[“Username”];
$password = $params[“Password”];
$testmode = $params[“TestMode”];
$tld = $params[“tld”];
$sld = $params[“sld”];
$domain = $params[“sld”] . “.” . $params[“tld”];
try {
$epp = new myfredEPP();
$epp->Login();
$epp->Process();
$xml = $epp->eppDomainInfo($params[“sld”] . “.” . $params[“tld”], $params[“transfersecret”]);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “EPP Domain Information – Contact Update”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
$Registrant_old = $doc->getElementsByTagName(“registrant”)->item(0)->nodeValue;
$Admin_old = $doc->getElementsByTagName(“admin”)->item(0)->nodeValue;
$registrantContactID = $epp->eppContactId(16, “”, “”, 1);
$xml = $epp->eppContactCheck($registrantContactID);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “EPP Contact Check”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
$contactAvailable = $doc->getElementsByTagName(“id”)->item(0)->getAttribute(“avail”);
if ($contactAvailable != “0” && $contactAvailable != “false”) {
$postalInfo = array(“loc” => array(
“name” => $params[“contactdetails”][“Registrant”][“Name”],
“org” => $params[“contactdetails”][“Registrant”][“Company Name”],
“street” => array(0 => $params[“contactdetails”][“Registrant”][“Address 1”], 1 => “”, 2 => “”),
“city” => $params[“contactdetails”][“Registrant”][“City”],
“sp” => $params[“contactdetails”][“Registrant”][“State”],
“pc” => $params[“contactdetails”][“Registrant”][“Zip”],
“cc” => $params[“contactdetails”][“Registrant”][“Country”]
));
$xml = $epp->eppContactCreate($registrantContactID, $postalInfo, $params[“contactdetails”][“Registrant”][“Phone Number”], “”, $params[“contactdetails”][“Registrant”][“Email Address”], $epp->eppKey(), “”, “”, “”, “”);
logModuleCall(“fredEPP”, “EPP Contact Create”, $xml, “”);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “EPP Contact Create”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
}
$adminContactID = $epp->eppContactId(16, “”, “”, 1);
$xml = $epp->eppContactCheck($adminContactID);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “EPP Admin Contact Check”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
$contactAvailable = $doc->getElementsByTagName(“id”)->item(0)->getAttribute(“avail”);
if ($contactAvailable != “0” && $contactAvailable != “false”) {
$postalInfo = array(“” => array(
“name” => $params[“contactdetails”][“Admin”][“Name”],
“org” => $params[“contactdetails”][“Admin”][“Company Name”],
“street” => array(0 => $params[“contactdetails”][“Admin”][“Address 1”], 1 => “”, 2 => “”),
“city” => $params[“contactdetails”][“Admin”][“City”],
“sp” => $params[“contactdetails”][“Admin”][“State”],
“pc” => $params[“contactdetails”][“Admin”][“Zip”],
“cc” => $params[“contactdetails”][“Admin”][“Country”]
));
$xml = $epp->eppContactCreate($adminContactID, $postalInfo, $params[“contactdetails”][“Admin”][“Phone Number”], “”, $params[“contactdetails”][“Admin”][“Email Address”], $epp->eppKey(), “”, “”, “”, “”);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “Admin EPP Contact Create”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
$adminContact[0] = $adminContactID;
}
$newcontact[0][“type”] = “registrant”;
$newcontact[0][“id”] = $registrantContactID;
$newcontact[1][“type”] = “admin”;
$newcontact[1][“id”] = $adminContactID;
$oldcontact[0] = $Registrant_old;
$oldcontact[1] = $Admin_old;
$xml = $epp->eppDomainContactUpdate($domain, $newcontact, $oldContact);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “EPP Domain Contact Update”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
} catch (Exception $e) {
$values[“error”] = $e->getMessage();
return $values;
}
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout Auth”, $xml, $response);
}
return $ values;
}
Auth Code Retrieval
Get EPP Code
The fred_GetEPPCode function retrieves the EPP code for a domain transfer.
function fred_GetEPPCode($params) {
$username = $params[“Username”];
$password = $params[“Password”];
$testmode = $params[“TestMode”];
$tld = $params[“tld”];
$sld = $params[“sld”];
try {
$epp = new myfredEPP();
$epp->Login();
$epp->Process();
$xml = $epp->eppDomainInfo($params[“sld”] . “.” . $params[“tld”], $params[“transfersecret”]);
$response = $epp->request($xml);
$doc = new DOMDocument();
$doc->loadXML($response);
logModuleCall(“fredEPP”, “EPP Domain Information – EPP Code”, $xml, $response);
$messagecode = $doc->getElementsByTagName(“result”)->item(0)->getAttribute(“code”);
$message = $doc->getElementsByTagName(“msg”)->item(0)->nodeValue;
if ($messagecode != “1000”) {
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout”, $xml, $response);
}
$values[“error”] = $messagecode . ” – ” . $message;
return $values;
}
$auth = $doc->getElementsByTagName(“authInfo”)->item(0)->nodeValue;
$values[“eppcode”] = $auth;
} catch (Exception $e) {
$values[“error”] = $e->getMessage();
return $values;
}
$xml = $epp->eppLogout();
$response = $epp->request($xml);
if ($params[“debug”] == “on”) {
logModuleCall(“fredEPP”, “EPP Logout Auth”, $xml, $response);
}
return $values;
}
Nameserver Management
Register Nameserver
The fred_RegisterNameserver function registers a new nameserver.
function fred_RegisterNameserver($params) {
$username = $params[“Username”];
$password = $params[“Password”];
$testmode = $params[“TestMode”];
$tld = $params[“tld”];
$sld = $params[“sld”];
$nameserver = $params[“nameserver”];
$ipaddress = $params[“ipaddress”];
# Put your code to register the nameserver here
# If error, return the error message in the value below
$values[“error”] = $error;
return $values;
}
Modify Nameserver
The fred_ModifyNameserver function modifies the IP address of an existing nameserver.
phpCopy codefunction fred_ModifyNameserver($params) {
$username = $params[“Username”];
$password = $params[“Password”];
$testmode = $params[“TestMode”];
$tld = $params[“tld”];
$sld = $params[“sld”];
$nameserver = $params[“nameserver”];
$currentipaddress = $params[“currentipaddress”];
$newipaddress = $params[“newipaddress”];
# Put your code to update the nameserver here
# If error, return the error message in the value below
$values[“error”] = $error;
return $values;
}
Delete Nameserver
The fred_DeleteNameserver function deletes an existing nameserver.
phpCopy codefunction fred_DeleteNameserver($params) {
$username = $params[“Username”];
$password = $params[“Password”];
$testmode = $params[“TestMode”];
$tld = $params[“tld”];
$sld = $params[“sld”];
$nameserver = $params[“nameserver”];
# Put your code to delete the nameserver here
# If error, return the error message in the value below
$values[“error”] = $error;
return $values;
}
This documentation provides an overview of how the Free Registry for ENUM and Domains (FRED) API works, based on the provided domain operations code. Each function is designed to handle specific domain management tasks, such as registration, transfer, renewal, and contact management. The functions interact with the EPP (Extensible Provisioning Protocol) to perform these tasks and handle responses accordingly.
