How to check an availability of multiple domains

Discussion in 'PHP' started by lelkoun, Mar 4, 2011.

  1. #1
    I use the following code to check if a domain is available (API manual). How to make it work for multiple domains, not just one at a time - when I would use a textarea with domains on each row?

    <?
    $client = new SoapClient(
            null, 
            array(
                "location" => "https://soap.subreg.cz/cmd.php",
                "uri" => "	https://soap.subreg.cz/cmd.php"
                )
            );
    
    $params = array ( 
        "data" => array (
            "login" => "login",
            "password" => "seecretpassword",
        )
    );
    
    $response = $client->__call("Login",$params);
    
    $token = $response["data"]["ssid"];
    
    unset($params);
    
    
    
    $params = array (
        "data" => array (
                "ssid" => $token,
                "domain" => 'google.com',
        )
    );
    
    $response = $client->__call("Check_Domain",$params);
    print_r($response);
    
    ?>
    
    PHP:
    Thank you for your answers.
     
    lelkoun, Mar 4, 2011 IP
  2. G3n3s!s

    G3n3s!s Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    80
    #2
    foreach ($list_of_domains as $domain)
    {
    //check domain function here
    }

    (just for OP) - prostě si dej ty domény do arraye a foreachem to vyzkoušej postupně
     
    G3n3s!s, Mar 5, 2011 IP
  3. lelkoun

    lelkoun Active Member

    Messages:
    288
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #3
    I've already tried this, but the remote server always returns something like this:

    Array([status]=>error[error]=>Array([errormsg]=>UnsupportedTLD[errorcode]=>Array([major]=>501[minor]=>1002)))
    Array([status]=>ok[data]=>Array([name]=>google.com[avail]=>0))
    PHP:
    Only the last domain is always being successfully checked, the previous are not.
     
    lelkoun, Mar 7, 2011 IP
  4. G3n3s!s

    G3n3s!s Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    80
    #4
    Did you read that?

    [errormsg]=>UnsupportedTLD = unsupported domain shortcut (for example they support only .com, .net, .WHATEVER)
     
    G3n3s!s, Mar 8, 2011 IP
  5. SSC

    SSC Active Member

    Messages:
    995
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    80
    #5
    exactly!

    the whole solution lies in the error message itself (([errormsg]=>UnsupportedTLD)
    which means that only top level domains are supported not sub-domains,
    like you.yourdomainname.com would probably give an error but, youdomainname.com wouldn't
     
    SSC, Mar 8, 2011 IP
  6. lelkoun

    lelkoun Active Member

    Messages:
    288
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #6
    Well, the script prints error messages even if the TLDs are correct, for example:

    INPUT:
    google.com
    yahoo.com
    microsoft.com
    bing.com
    Code (markup):
    OUTPUT:
    Array ( [status] => error [error] => Array ( [errormsg] => Unsupported TLD [errorcode] => Array ( [major] => 501 [minor] => 1002 ) ) ) Array ( [status] => error [error] => Array ( [errormsg] => Unsupported TLD [errorcode] => Array ( [major] => 501 [minor] => 1002 ) ) ) Array ( [status] => error [error] => Array ( [errormsg] => Unsupported TLD [errorcode] => Array ( [major] => 501 [minor] => 1002 ) ) ) Array ( [status] => ok [data] => Array ( [name] => bing.com [avail] => 0 ) ) 
    Code (markup):
    The last domain (bing.com) was checked, but previous domains were not. Why?
     
    lelkoun, Mar 8, 2011 IP
  7. lelkoun

    lelkoun Active Member

    Messages:
    288
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #7
    Now I know why it did not work - for some reason there was another char after ".com" except the last domain.

    trim($val)
    PHP:
     
    lelkoun, Mar 9, 2011 IP