This documentation has moved

XML API documentation can now be found at developer.openprovider.com. This page will remain available until September 2026, but will no longer be updated.

The XML API itself is not changing. Your existing integration continues to work.

Bulk checkDomainRequest

From Openprovider API documentation

Revision as of 15:59, 12 December 2016 by WikiSysop (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Before using this script, please make sure to read API General Examples

<?php
require_once('API.php');
$api = new OP_API('https://api.openprovider.eu');

$username = '--';
$password = '--';

if (!preg_match('/^[a-z\d\-]+$/i', $_SERVER['argv'][1])) {
  die("Provide a domain name (ASCII, without extension) and an optional limit. Syntax:\n    check-bulk.php somedomain [limit]\n\n");
}
if (isset($_SERVER['argv'][2]) && !preg_match('/^\d+$/', $_SERVER['argv'][2])) {
  die("Provide a domain name (ASCII, without extension) and an optional limit. Syntax:\n    check-bulk.php somedomain [limit]\n\n");
}

$domain   = $_SERVER['argv'][1]; // domain name without extension
$limit    = $_SERVER['argv'][2] ? $_SERVER['argv'][2] : NULL; // stop processing this script after this number of checks

$request = new OP_Request;
$request->setCommand('searchExtensionRequest')
  ->setAuth(array('username' => $username, 'password' => $password))
  ->setArgs(array(
    'limit' => 3000,
    'status' => 'ACT',
    'onlyNames' => true,
  ));
$reply = $api->process($request);
$res = $reply->getValue();

foreach ($res['results'] as $ext) {
  $request = new OP_Request;
  $request->setCommand('checkDomainRequest')
    ->setAuth(array('username' => $username, 'password' => $password))
    ->setArgs(array(
      'domains' => array(
        array(
          'name' => $domain,
          'extension' => $ext,
        ),
      )
    ));
  $reply = $api->process($request);
  if ($reply->getFaultCode() == 0) {
    $res = $reply->getValue();
    echo $domain.'.'.$ext."\t".$res[0]['status']."\n";
  }
  else {
    echo $domain.'.'.$ext."\t".$reply->getFaultCode().': '.$reply->getFaultString()."\n";
  }
  if ($limit && ++$cnt >= $limit) break;
}

?>
Views
Personal tools