示例#1
0
 public function process(OP_Request $r)
 {
     $this->doDebug($r->getRaw());
     $msg = $r->getRaw();
     $str = $this->_send($msg);
     if (!$str) {
         throw new OP_API_Exception('Bad reply');
     }
     $this->doDebug($str);
     return new OP_Reply($str);
 }
示例#2
0
 public function process(OP_Request $r)
 {
     if ($this->debug) {
         echo $r->getRaw() . "\n";
     }
     $msg = $r->getRaw();
     $str = $this->_send($msg);
     if (!$str) {
         throw new OP_API_Exception('Bad reply');
     }
     if ($this->debug) {
         echo $str . "\n";
     }
     return new OP_Reply($str);
 }
示例#3
0
 /**
  * Validate the elements data against the rule
  *
  * @param   string  $data           To check
  * @param   int     $repeatCounter  Repeat group counter
  *
  * @return  bool  true if validation passes, false if fails
  */
 public function validate($data, $repeatCounter)
 {
     $params = $this->getParams();
     $username = $params->get('openprovider_username');
     $password = $params->get('openprovider_password');
     $data = strtolower($data);
     // Strip www. from front
     if (substr($data, 0, 4) == 'www.') {
         $data = substr($data, 4, strlen($data));
     }
     list($domain, $extension) = explode('.', $data, 2);
     $api = new OP_API('https://api.openprovider.eu');
     $args = array('domains' => array(array('name' => $domain, 'extension' => $extension)));
     $request = new OP_Request();
     $request->setCommand('checkDomainRequest')->setAuth(array('username' => $username, 'password' => $password))->setArgs($args);
     $reply = $api->setDebug(0)->process($request);
     $res = $reply->getValue();
     return $res[0]['status'] === 'active' ? false : true;
 }
示例#4
0
require_once 'API.php';
$username = "";
$password = "";
// Create a new API connection
$api = new OP_API('https://api.openprovider.eu');
$request = new OP_Request();
$request->setCommand('createCustomerRequest')->setAuth(array('username' => $username, 'password' => $password))->setArgs(array('companyName' => 'Company Ltd', 'name' => array('initials' => 'J.A.', 'firstName' => 'John', 'prefix' => "", 'lastName' => 'Jones'), 'vat' => null, 'gender' => 'M', 'phone' => array('countryCode' => '+31', 'areaCode' => '383', 'subscriberNumber' => '1231212'), 'fax' => array('countryCode' => '+31', 'areaCode' => '383', 'subscriberNumber' => '1231213'), 'address' => array('street' => 'Main Avenue', 'number' => '2', 'suffix' => 'a', 'zipcode' => '8817 AB', 'city' => 'Rotterdam', 'state' => null, 'country' => 'NL'), 'email' => '*****@*****.**', 'additionalData' => array('birthDate' => '1958-12-03', 'companyRegistrationCity' => 'London', 'companyRegistrationNumber' => '7723601', 'companyRegistrationSubscriptionDate' => '2003-09-12')));
$reply = $api->setDebug(1)->process($request);
$response = $reply->getValue();
$handle = $response['handle'];
echo "Code: " . $reply->getFaultCode() . "\n";
echo "Error: " . $reply->getFaultString() . "\n";
echo "Handle: " . $handle . "\n";
echo "\n---------------------------------------\n";
$request = new OP_Request();
$request->setCommand('deleteCustomerRequest')->setAuth(array('username' => $username, 'password' => $password))->setArgs(array('handle' => $handle));
$reply = $api->setDebug(1)->process($request);
echo "\n---------------------------------------\n";
$request = new OP_Request();
$request->setCommand('retrieveDomainRequest')->setAuth(array('username' => $username, 'password' => $password))->setArgs(array('domain' => array('name' => 'openprovider', 'extension' => 'nl'), 'withAdditionalData' => 0));
$reply = $api->setDebug(1)->process($request);
echo "Code: " . $reply->getFaultCode() . "\n";
echo "Error: " . $reply->getFaultString() . "\n";
echo "Value: " . print_r($reply->getValue(), true) . "\n";
echo "\n---------------------------------------\n";
$request = new OP_Request();
$request->setCommand('checkDomainRequest')->setAuth(array('username' => $username, 'password' => $password))->setArgs(array('domains' => array(array('name' => 'openprovider', 'extension' => 'nl'), array('name' => 'non-existing-domain', 'extension' => 'co.uk'))));
$reply = $api->setDebug(1)->process($request);
print_r($reply->getValue());
echo "\n---------------------------------------\n";
echo "Finished example script\n\n";