當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


PHP WHMCS DomainGetNameservers用法及代碼示例

獲取域的當前名稱服務器。

連接到注冊商並獲取域的名稱服務器

請求參數

參數 類型 說明 必需的
action string “DomainGetNameservers” Required
domainid int 要獲取其名稱服務器的域的 id Required

響應參數

參數 類型 說明
result string 操作結果:成功或錯誤
ns1 string 域上的第一個名稱服務器
ns2 string 域上的第二個域名服務器
ns3 string 域上的第三個名稱服務器
ns4 string 域上的第四個域名服務器
ns5 string 域上的第五個域名服務器

示例請求 (CURL)

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.example.com/includes/api.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
    http_build_query(
        array(
            'action' => 'DomainGetNameservers',
            // See https://developers.whmcs.com/api/authentication
            'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
            'password' => 'SECRET_OR_HASHED_PASSWORD',
            'domainid' => '1',
            'responsetype' => 'json',
        )
    )
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);

示例請求(本地 API)

$command = 'DomainGetNameservers';
$postData = array(
    'domainid' => '1',
);
$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later

$results = localAPI($command, $postData, $adminUsername);
print_r($results);

示例響應 JSON

{
    "result": "success",
    "ns1": "ns1.example.com",
    "ns2": "ns1.example.com"
}

錯誤響應

可能的錯誤條件響應包括:

  • 未找到域 ID
  • 不支持注冊器函數
  • 注冊商錯誤消息

相關用法


注:本文由純淨天空篩選整理自whmcs.com大神的英文原創作品 DomainGetNameservers。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。