当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。