0

I am trying to use my test API key to create a new test domain and I receive an 'invalid key error. I can execute the version check code, but not domain code?

<?php
// Library installed from PEAR
require_once 'XML/RPC2/Client.php';

$apikey = 'xxxxxxx';

$domain = "mydomain.net";
$domain_api = XML_RPC2_Client::create(
    'https://rpc.gandi.net/xmlrpc/',
    array( 'prefix' => 'domain.' )
);
$result = $domain_api->available($apikey, array($domain));
print_r($result);
/*
Array
(
    [mydomain.net] => pending
)
*/
while ( $result[$domain] == 'pending') {
    usleep(700000);
    $result = $domain_api->available($apikey, array($domain));
}
//print_r($result);
/*
Array
(
    [mydomain.net] => unavailable
)
*/

// dump the result
print_r( $result );
?>

error:

Fatal error: Uncaught exception 'XML_RPC2_FaultException' with message 'Error on object : OBJECT_ACCOUNT (CAUSE_NORIGHT) [Invalid API key]' in /home2/path/php/XML/RPC2/Backend/Xmlrpcext/Client.php:131 Stack trace: #0 /home2/path/public_html/buydomain/index.php(66): XML_RPC2_Backend_Xmlrpcext_Client->__call('can_associate_d...', Array) #1 /home2/path/public_html/buydomain/index.php(66): XML_RPC2_Backend_Xmlrpcext_Client->can_associate_domain('My_KEY...', 'FLN123-GANDI', Array) #2 {main} thrown in /home2/path/php/XML/RPC2/Backend/Xmlrpcext/Client.php on line 131

1 Answers1

1

This is an old question, but I'll answer for the benefit of anyone stumbling across this. As per the Gandi API documentation, you cannot call a method called 'create' directly. This is true of other parts of the API, such as contact.create().

Here is Gandi's own PHP example:

    <?php
    $domain_spec = array(
        'owner' => 'FLN123-GANDI',
        'admin' => 'FLN123-GANDI',
        'bill' => 'FLN123-GANDI',
        'tech' =>'FLN123-GANDI',
        'nameservers' => array('a.dns.gandi-ote.net', 'b.dns.gandi-ote.net',
                               'c.dns.gandi-ote.net'),
        'duration' => 1);
    $op = $domain_api->__call('create', array($apikey, 'mydomain.net',
        $domain_spec));
    ?>

As you can see, $domain_api->create($apikey,'mydomain.net',$domain_spec) becomes $domain_api->__call('create', array($apikey,'mydomain.net',$domain_spec)).

Sam_Butler
  • 293
  • 2
  • 14