6/4/2007 18:58
<? class Dynadot{ var $version = "1.0"; var $key = "Your API Key"; function search($domains, $combine = false){ $i = 0; $query = ""; foreach($domains as $key => $domain){ $domain = strtolower($domain); if($i == 0){ $query .= "domain".$i."=".$domain; }else{ $query .= "&domain".$i."=".$domain; } $keys[$i] = array($key, $domain); $i++; } $f = file_get_contents('https://www.dynadot.com/api.html?version='.$this->version.'&key='.$this->version.'&command=search&'.$domain); $lines = explode("\n", $f); foreach($lines as $line){ $parts = explode(',', $line); if($parts[3] == 'error' || $parts[3] == 'offline'){ $ret[substr($parts[0], -1, 1)] = '2'; }else{ if($parts[3] == 'yes'){ $ret[substr($parts[0], -1, 1)] = '1'; }else{ $ret[substr($parts[0], -1, 1)] = '0'; } } } if($combine){ foreach($ret as $key => $avail){ $return[$keys[$key]['1']] = $avail; } return $return; }else{ foreach($ret as $key => $avail){ $return[$keys[$key]['0']] = $avail; } return $return; } } } $dynadot = new Dynadot(); //Usage of search: // Function search( array $domains, [bol $combine]); // The domains should be feed into the function VIA array. Example: // $domains = array([0] => 'test.com', [1] => 'hello.net', [2] => 'thisdomainisclearlyavailable.com'); // bol $combine determines the output. If not stated, or if false, it will return an array using the same keys as sent. Using the example above, it will return it using 0 for test.com, 1 for hello.net, and so on. // If set to true, it will use the domain as an array key. // The array it spits out either has a 0, 1 or, 2 for a value. 0 means taken, 1 means available, and 2 means error. $domains = $dynadot->search(array('mydomain.com', 'mydomain.net'), true); print_r($domains); ?> So far I only have search, I'll work on register later. NOTE: I don't have a dynadot API account, so there is no way to test it. I'd like to rely on other people to test it for me, so please let me know if you stumble upon any errors. Thanks.
Reply
Quote Like Sorry, you do not have permission to post in our forums. Please contact our Support Team if you have any questions.
[quote]c-web says: <?
class Dynadot{
var $version = "1.0";
var $key = "Your API Key";
function search($domains, $combine = false){
$i = 0;
$query = "";
foreach($domains as $key => $domain){
$domain = strtolower($domain);
if($i == 0){
$query .= "domain".$i."=".$domain;
}else{
$query .= "&domain".$i."=".$domain;
}
$keys[$i] = array($key, $domain);
$i++;
}
$f = file_get_contents('https://www.dynadot.com/api.html?version='.$this->version.'&key='.$this->version.'&command=search&'.$domain);
$lines = explode("\n", $f);
foreach($lines as $line){
$parts = explode(',', $line);
if($parts[3] == 'error' || $parts[3] == 'offline'){
$ret[substr($parts[0], -1, 1)] = '2';
}else{
if($parts[3] == 'yes'){
$ret[substr($parts[0], -1, 1)] = '1';
}else{
$ret[substr($parts[0], -1, 1)] = '0';
}
}
}
if($combine){
foreach($ret as $key => $avail){
$return[$keys[$key]['1']] = $avail;
}
return $return;
}else{
foreach($ret as $key => $avail){
$return[$keys[$key]['0']] = $avail;
}
return $return;
}
}
}
$dynadot = new Dynadot();
//Usage of search:
// Function search( array $domains, [bol $combine]);
// The domains should be feed into the function VIA array. Example:
// $domains = array([0] => 'test.com', [1] => 'hello.net', [2] => 'thisdomainisclearlyavailable.com');
// bol $combine determines the output. If not stated, or if false, it will return an array using the same keys as sent. Using the example above, it will return it using 0 for test.com, 1 for hello.net, and so on.
// If set to true, it will use the domain as an array key.
// The array it spits out either has a 0, 1 or, 2 for a value. 0 means taken, 1 means available, and 2 means error.
$domains = $dynadot->search(array('mydomain.com', 'mydomain.net'), true);
print_r($domains);
?>
So far I only have search, I'll work on register later.
NOTE: I don't have a dynadot API account, so there is no way to test it. I'd like to rely on other people to test it for me, so please let me know if you stumble upon any errors. Thanks.[/quote]
Quote
<?
class Dynadot{
var $version = "1.0";
var $key = "Your API Key";
function search($domains, $combine = false){
$i = 0;
$query = "";
foreach($domains as $key => $domain){
$domain = strtolower($domain);
if($i == 0){
$query .= "domain".$i."=".$domain;
}else{
$query .= "&domain".$i."=".$domain;
}
$keys[$i] = array($key, $domain);
$i++;
}
$f = file_get_contents('https://www.dynadot.com/api.html?version='.$this->version.'&key='.$this->version.'&command=search&'.$domain);
$lines = explode("\n", $f);
foreach($lines as $line){
$parts = explode(',', $line);
if($parts[3] == 'error' || $parts[3] == 'offline'){
$ret[substr($parts[0], -1, 1)] = '2';
}else{
if($parts[3] == 'yes'){
$ret[substr($parts[0], -1, 1)] = '1';
}else{
$ret[substr($parts[0], -1, 1)] = '0';
}
}
}
if($combine){
foreach($ret as $key => $avail){
$return[$keys[$key]['1']] = $avail;
}
return $return;
}else{
foreach($ret as $key => $avail){
$return[$keys[$key]['0']] = $avail;
}
return $return;
}
}
}
$dynadot = new Dynadot();
//Usage of search:
// Function search( array $domains, [bol $combine]);
// The domains should be feed into the function VIA array. Example:
// $domains = array([0] => 'test.com', [1] => 'hello.net', [2] => 'thisdomainisclearlyavailable.com');
// bol $combine determines the output. If not stated, or if false, it will return an array using the same keys as sent. Using the example above, it will return it using 0 for test.com, 1 for hello.net, and so on.
// If set to true, it will use the domain as an array key.
// The array it spits out either has a 0, 1 or, 2 for a value. 0 means taken, 1 means available, and 2 means error.
$domains = $dynadot->search(array('mydomain.com', 'mydomain.net'), true);
print_r($domains);
?>
So far I only have search, I'll work on register later.
NOTE: I don't have a dynadot API account, so there is no way to test it. I'd like to rely on other people to test it for me, so please let me know if you stumble upon any errors. Thanks. Edit