/** * Create a new whois contact * * @param Whois $whois The whois information for the new contact * @param string $type The contact type. This is only used to access the right data in the $whois object * * @return bool Is new contact was created succesfully or not * * @throws Api_Odr_Exception */ public function createContact($whois, $type = HANDLE_OWNER) { if (!$this->_checkLogin()) { return false; } $contact = $this->mapWhoisToContact($whois, $type); try { $this->odr->createContact($contact); } catch (Api_Odr_Exception $e) { $this->Error[] = $e->getMessage(); return false; } $result = $this->odr->getResult(); return $this->_checkResult(empty($result['response']['data']['id']) ? false : $result['response']['data']['id']); }
<?php // Require ODR API demo class require_once '../Api/Odr.php'; // Configuration array, with user API Keys $config = array('api_key' => '#API_KEY#', 'api_secret' => '#API_SECRET#'); // We assume that user already sent all the data to us through request $data = $_REQUEST; // Create new instance of API demo class $demo = new Api_Odr($config); // Login into API $demo->login(); $loginResult = $demo->getResult(); if ($loginResult['status'] === 'error') { echo 'Can\'t login, reason - ' . $loginResult['response']; exit(1); } // Create new contact, by passing request data $demo->createContact($data); // Get result of request $result = $demo->getResult(); if ($result['status'] !== 'success') { echo 'Following error occured: ' . $result['response']; exit(1); } $result = $result['response']; // Contact successfully created, yay! echo 'Contact "' . $result['contact_first_name'] . ' ' . $result['contact_last_name'] . '" created';