Example #1
0
/**
 * Gets the contacts on the domain
 * @param $params
 * @return array
 */
function domainbox_GetContactDetails($params)
{
    $authParameters = getAuthParameters($params);
    $apiEndpoint = $params["TestMode"] ? "https://sandbox.domainbox.net/?WSDL" : "https://live.domainbox.net/?WSDL";
    $queryDomainContactsParameters = new QueryDomainContactsParameters();
    $queryDomainContactsParameters->DomainName = $params["sld"] . '.' . $params["tld"];
    try {
        $parameters = array('AuthenticationParameters' => $authParameters, 'CommandParameters' => $queryDomainContactsParameters);
        $client = new SoapClient($apiEndpoint, array('soap_version' => SOAP_1_2));
        $result = $client->QueryDomainContacts($parameters);
        $result = $result->QueryDomainContactsResult;
        if ($result->ResultCode == 100) {
            $registrant = $result->Contacts->Registrant;
            $admin = $result->Contacts->Admin;
            $tech = $result->Contacts->Tech;
            $billing = $result->Contacts->Billing;
            $values['Registrant']['Name'] = $registrant->Name;
            $values['Registrant']['Organisation'] = $registrant->Organisation;
            $values['Registrant']['Street 1'] = $registrant->Street1;
            $values['Registrant']['Street 2'] = $registrant->Street2;
            $values['Registrant']['Street 3'] = $registrant->Street3;
            $values['Registrant']['City'] = $registrant->City;
            $values['Registrant']['State'] = $registrant->State;
            $values['Registrant']['Postal Code'] = $registrant->Postcode;
            $values['Registrant']['Country Code'] = $registrant->CountryCode;
            $values['Registrant']['Telephone'] = $registrant->Telephone;
            $values['Registrant']['Fax'] = $registrant->Fax;
            $values['Registrant']['Email'] = $registrant->Email;
            if ($admin != null) {
                $values['Admin']['Name'] = $admin->Name;
                $values['Admin']['Organisation'] = $admin->Organisation;
                $values['Admin']['Street 1'] = $admin->Street1;
                $values['Admin']['Street 2'] = $admin->Street2;
                $values['Admin']['Street 3'] = $admin->Street3;
                $values['Admin']['City'] = $admin->City;
                $values['Admin']['State'] = $admin->State;
                $values['Admin']['Postal Code'] = $admin->Postcode;
                $values['Admin']['Country Code'] = $admin->CountryCode;
                $values['Admin']['Telephone'] = $admin->Telephone;
                $values['Admin']['Fax'] = $admin->Fax;
                $values['Admin']['Email'] = $admin->Email;
            }
            if ($billing != null) {
                $values['Billing']['Name'] = $billing->Name;
                $values['Billing']['Organisation'] = $billing->Organisation;
                $values['Billing']['Street 1'] = $billing->Street1;
                $values['Billing']['Street 2'] = $billing->Street2;
                $values['Billing']['Street 3'] = $billing->Street3;
                $values['Billing']['City'] = $billing->City;
                $values['Billing']['State'] = $billing->State;
                $values['Billing']['Postal Code'] = $billing->Postcode;
                $values['Billing']['Country Code'] = $billing->CountryCode;
                $values['Billing']['Telephone'] = $billing->Telephone;
                $values['Billing']['Fax'] = $billing->Fax;
                $values['Billing']['Email'] = $billing->Email;
            }
            if ($tech != null) {
                $values['Technical']['Name'] = $tech->Name;
                $values['Technical']['Organisation'] = $tech->Organisation;
                $values['Technical']['Street 1'] = $tech->Street1;
                $values['Technical']['Street 2'] = $tech->Street2;
                $values['Technical']['Street 3'] = $tech->Street3;
                $values['Technical']['City'] = $tech->City;
                $values['Technical']['State'] = $tech->State;
                $values['Technical']['Postal Code'] = $tech->Postcode;
                $values['Technical']['Country Code'] = $tech->CountryCode;
                $values['Technical']['Telephone'] = $tech->Telephone;
                $values['Technical']['Fax'] = $tech->Fax;
                $values['Technical']['Email'] = $tech->Email;
            }
        } else {
            $values["error"] = $result->ResultMsg;
        }
    } catch (Exception $e) {
        $values["error"] = "There was an error communicating with Domainbox";
    }
    return $values;
}