我正在尝试对Gandi API进行API调用。我可以成功调用domain.list()并接收正确的输出。但我无法解释如何在API文档中指示附加.zone来获取区域数据。 .i.e。 domain.zone.info()
API调用doc:
http://doc.rpc.gandi.net/domain/reference.html#domain.zone.info
代码:
require_once 'gandikey.php';
$domain = $_POST['domain'];
$domain_api = XML_RPC2_Client::create(
'https://rpc.gandi.net/xmlrpc/',
array('prefix' => 'domain.')
);
$op = $domain_api->__call('zone.info', array($apikey, '14382539'));
echo '<pre>';
var_dump($op);
echo '</pre>';
输出:
Fatal error: Uncaught exception 'XML_RPC2_FaultException' with message 'Error on object : OBJECT_UNKNOWN (CAUSE_BADPARAMETER) [invalid method parameter(s)]' in /usr/local/share/pear/XML/RPC2/Exception.php:283 Stack trace: #0 /usr/local/share/pear/XML/RPC2/Backend/Php/Response.php(129): XML_RPC2_FaultException::createFromDecode(Object(SimpleXMLElement)) #1 /usr/local/share/pear/XML/RPC2/Backend/Php/Client.php(122): XML_RPC2_Backend_Php_Response::decode(Object(SimpleXMLElement)) #2 /usr/home/nyctelecomm/www/mkdomain/gandi-mkzone.php(56): XML_RPC2_Backend_Php_Client->__call('zone.info', Array) #3 {main} thrown in /usr/local/share/pear/XML/RPC2/Exception.php on line 283
如何从Gandi API获取域名区域信息?
答案 0 :(得分:0)
您需要传递整数作为第二个参数。在https://rpc.ote.gandi.net/xmlrpc/的测试环境中,
$domain_api->call("zone.info", [$apikey, "115553"]);`
因CAUSE_BADPARAMETER
例外而失败,而
$domain_api->call("zone.info", [$apikey, 115553]);
返回:
array (size=8)
'name' => string 'Default Gandi zone file' (length=23)
'versions' =>
array (size=1)
0 => int 1
'date_updated' =>
object(stdClass)[405]
public 'scalar' => string '20110705T14:12:19' (length=17)
public 'xmlrpc_type' => string 'datetime' (length=8)
public 'timestamp' => int 1309875139
'id' => int 115553
'owner' => string 'BACKEND1-GANDI' (length=14)
'version' => int 1
'domains' => int 1670
'public' => boolean true