【问题标题】:Fatal error: Uncaught exception 'XML_RPC2_FaultException' with message 'Error on object : OBJECT_ACCOUNT (CAUSE_NORIGHT) [Invalid API key]致命错误:未捕获的异常“XML_RPC2_FaultException”,消息“对象错误:OBJECT_ACCOUNT (CAUSE_NORIGHT) [API 密钥无效]
【发布时间】:2015-09-24 12:28:21
【问题描述】:

我正在尝试使用我的测试 API 密钥来创建一个新的测试域,我收到了 '无效的密钥错误。 我可以执行版本检查代码,但不能执行域代码?

<?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

【问题讨论】:

    标签: php api dns xml-rpc xmlrpcclient


    【解决方案1】:

    这是一个老问题,但我会回答任何绊倒这个问题的人的利益。根据Gandi API documentation,您不能直接调用名为“create”的方法。 API 的其他部分也是如此,例如contact.create()。

    这是 Gandi 自己的 PHP 示例:

        <?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));
        ?>
    

    如您所见,$domain_api-&gt;create($apikey,'mydomain.net',$domain_spec) 变为 $domain_api-&gt;__call('create', array($apikey,'mydomain.net',$domain_spec))。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多