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


PHP WHMCS GetClientsDetails用法及代碼示例

獲取特定客戶端的客戶端詳細信息

請注意,此函數在頂級數組中返回客戶端信息。此信息已棄用,可能會在 WHMCS 的未來版本中刪除。

請求參數

參數 類型 說明 必需的
action string “GetClientsDetails” Required
clientid int 獲取詳細信息的客戶端 ID。需要 $clientid 或 $email Optional
email string 要搜索的客戶的電子郵件地址 Optional
stats bool 還返回其他客戶端統計信息。 Optional

響應參數

參數 類型 說明
result string 操作結果:成功或錯誤
client array 客戶端的信息。
stats array 返回的客戶端的其他統計信息。

示例請求 (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' => 'GetClientsDetails',
            // See https://developers.whmcs.com/api/authentication
            'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
            'password' => 'SECRET_OR_HASHED_PASSWORD',
            'clientid' => '1',
            'stats' => true,
            'responsetype' => 'json',
        )
    )
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);

示例請求(本地 API)

$command = 'GetClientsDetails';
$postData = array(
    'clientid' => '1',
    'stats' => true,
);
$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later

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

示例響應 JSON

{
    "result": "success",
    "client": {
        "client_id": 1,
        "owner_user_id": 1,
        "userid": 1,
        "id": 1,
        "uuid": "f08ea4d1-c578-441a-9b0a-aa3aff8b1acf",
        "firstname": "Test",
        "lastname": "Client",
        "fullname": "Test Client",
        "companyname": "",
        "email": "[email protected]",
        "address1": "123 Test Street",
        "address2": "",
        "city": "Test",
        "fullstate": "Tester",
        "state": "Tester",
        "postcode": "TE5 5ST",
        "countrycode": "GB",
        "country": "GB",
        "phonenumber": "01234567890",
        "tax_id": "",
        "email_preferences": {
            "general": "1",
            "invoice": "1",
            "support": "1",
            "product": "1",
            "domain": "1",
            "affiliate": "1"
        },
        "statecode": "Tester",
        "countryname": "United Kingdom",
        "phonecc": "44",
        "phonenumberformatted": "+44.1234567890",
        "telephoneNumber": "+44.1234567890",
        "billingcid": 0,
        "notes": "",
        "currency": 1,
        "defaultgateway": "",
        "groupid": 0,
        "status": "Active",
        "credit": "0.00",
        "taxexempt": false,
        "latefeeoveride": false,
        "overideduenotices": false,
        "separateinvoices": false,
        "disableautocc": false,
        "emailoptout": false,
        "marketing_emails_opt_in": true,
        "overrideautoclose": false,
        "allowSingleSignOn": 1,
        "email_verified": true,
        "language": "",
        "isOptedInToMarketingEmails": true,
        "lastlogin": "Date: 03\/10\/2016 10:26<br>IP Address:<br>Host:",
        "currency_code": "USD",
        "customfields": [
            {
                "id": 1,
                "value": "Custom Field Value"
            }
        ],
        "customfields1": "Custom Field Value",
        "users": {
            "user": [
                {
                    "id": 1,
                    "name": "Testing User",
                    "email": "[email protected]",
                    "is_owner": true
                }
            ]
        }
    },
    "stats": {
        "numdueinvoices": 19,
        "dueinvoicesbalance": "$2645.80 USD",
        "incredit": false,
        "creditbalance": "$0.00 USD",
        "grossRevenue": "$0.00 USD",
        "expenses": "$0.00 USD",
        "income": "$0.00 USD",
        "numoverdueinvoices": 19,
        "overdueinvoicesbalance": "$2645.80 USD",
        "numDraftInvoices": 0,
        "draftInvoicesBalance": "$0.00 USD",
        "numunpaidinvoices": 19,
        "unpaidinvoicesamount": "$2645.80 USD",
        "numpaidinvoices": 0,
        "paidinvoicesamount": "$0.00 USD",
        "numcancelledinvoices": 0,
        "cancelledinvoicesamount": "$0.00 USD",
        "numrefundedinvoices": 0,
        "refundedinvoicesamount": "$0.00 USD",
        "numcollectionsinvoices": 0,
        "collectionsinvoicesamount": "$0.00 USD",
        "numpaymentpendinginvoices": 0,
        "paymentpendinginvoicesamount": "$0.00 USD",
        "productsnumactivehosting": 0,
        "productsnumhosting": 0,
        "productsnumactivereseller": 0,
        "productsnumreseller": 0,
        "productsnumactiveservers": 0,
        "productsnumservers": 0,
        "productsnumactiveother": 2,
        "productsnumother": 2,
        "productsnumactive": 2,
        "productsnumtotal": 2,
        "numactivedomains": 2,
        "numdomains": 2,
        "numacceptedquotes": 0,
        "numquotes": 0,
        "numtickets": 0,
        "numactivetickets": 0,
        "numaffiliatesignups": 0,
        "isAffiliate": false
    }
}

警告響應

使用已刪除或標記為已棄用的 API 函數時會返回警告響應。我們建議遵循警告中的任何建議操作,以確保未來的兼容性。

可能的警告消息包括:

  • 信用卡相關參數現已棄用並已刪除。請改用GetPayMethods。

錯誤響應

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

  • 需要客戶端 ID 或電子郵件
  • 未找到客戶

相關用法


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