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


PHP WHMCS GetClientsProducts用法及代码示例


获取符合所提供标准的客户购买产品列表

请求参数

参数 类型 说明 必需的
action string “GetClientsProducts” Required
limitstart int 返回的日志数据的偏移量(默认值:0) Optional
limitnum int 返回的记录数(默认:25) Optional
clientid int 获取详细信息的客户端 ID。 Optional
serviceid int 获取详细信息的特定服务 ID Optional
pid int 获取详细信息的特定产品 ID Optional
domain string 获取服务详细信息的特定域 Optional
username2 string 获取详细信息的特定用户名 Optional

响应参数

参数 类型 说明
result string 操作结果:成功或错误
clientid int 搜索的特定客户端 ID
serviceid int 搜索的特定服务 ID
pid int 搜索的特定产品 ID
domain string 搜索的特定域
totalresults int 可用结果总数
startnumber int 返回结果的起始编号
numreturned int 返回的结果总数
products 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' => 'GetClientsProducts',
            // 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 = 'GetClientsProducts';
$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",
    "clientid": "1",
    "serviceid": null,
    "pid": null,
    "domain": null,
    "totalresults": "2",
    "startnumber": 0,
    "numreturned": 2,
    "products": {
        "product": [
            {
                "id": "1",
                "clientid": "1",
                "orderid": "1",
                "ordernumber": "456789",
                "pid": "1",
                "regdate": "2015-01-01",
                "name": "Starter",
                "translated_name": "Starter",
                "groupname": "Shared Hosting",
                "translated_groupname": "Shared Hosting",
                "domain": "demodomain.com",
                "dedicatedip": "",
                "serverid": "1",
                "servername": "Saturn",
                "serverip": "1.2.3.4",
                "serverhostname": "saturn.example.com",
                "suspensionreason": "",
                "firstpaymentamount": "12.95",
                "recurringamount": "12.95",
                "paymentmethod": "authorize",
                "paymentmethodname": "Credit Card",
                "billingcycle": "Monthly",
                "nextduedate": "2016-11-25",
                "status": "Terminated",
                "username": "demodoma",
                "password": "xxxxxxxx",
                "subscriptionid": "",
                "promoid": "0",
                "overideautosuspend": "",
                "overidesuspenduntil": "0000-00-00",
                "ns1": "",
                "ns2": "",
                "assignedips": "",
                "notes": "",
                "diskusage": "0",
                "disklimit": "0",
                "bwusage": "0",
                "bwlimit": "0",
                "lastupdate": "0000-00-00 00:00:00",
                "customfields": {
                    "customfield": []
                },
                "configoptions": {
                    "configoption": []
                }
            },
            {
                "id": "2",
                "clientid": "1",
                "orderid": "2",
                "pid": "3",
                "regdate": "2015-05-20",
                "name": "Plus",
                "translated_name": "Plus",
                "groupname": "Shared Hosting",
                "translated_groupname": "Shared Hosting",
                "domain": "demodomain2.net",
                "dedicatedip": "",
                "serverid": "2",
                "servername": "Pluto",
                "serverip": "2.3.4.5",
                "serverhostname": "pluto.example.com",
                "suspensionreason": "",
                "firstpaymentamount": "24.95",
                "recurringamount": "24.95",
                "paymentmethod": "paypal",
                "paymentmethodname": "PayPal",
                "billingcycle": "Monthly",
                "nextduedate": "2017-01-20",
                "status": "Active",
                "username": "demodom2",
                "password": "xxxxxxxx",
                "subscriptionid": "",
                "promoid": "0",
                "overideautosuspend": "",
                "overidesuspenduntil": "0000-00-00",
                "ns1": "",
                "ns2": "",
                "assignedips": "",
                "notes": "",
                "diskusage": "0",
                "disklimit": "0",
                "bwusage": "0",
                "bwlimit": "0",
                "lastupdate": "0000-00-00 00:00:00",
                "customfields": {
                    "customfield": []
                },
                "configoptions": {
                    "configoption": [
                        {
                            "id": "1",
                            "option": "Sample Config Option",
                            "type": "dropdown",
                            "value": "Selected option value"
                        }
                    ]
                }
            }
        ]
    }
}

相关用法


注:本文由纯净天空筛选整理自whmcs.com大神的英文原创作品 GetClientsProducts。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。