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


PHP WHMCS UpdateClientProduct用法及代码示例


更新客户端服务

请求参数

参数 类型 说明 必需的
action string “UpdateClientProduct” Required
serviceid int 要更新的客户端服务的 ID。 Required
pid int 与服务关联的包 ID。 Optional
serverid int 与服务关联的服务器 ID。 Optional
regdate string 服务的注册日期。格式:Y-m-d Optional
nextduedate string 服务的下一个到期日。格式:Y-m-d Optional
terminationdate string 更新服务的终止日期。格式:Y-m-d Optional
domain string 要更改的域名。 Optional
firstpaymentamount float 服务的第一笔付款数量。 Optional
recurringamount float 自动续订发票的经常性数量。 Optional
paymentmethod string 要关联的付款方式,采用系统格式(例如 paypal)。 Optional
billingcycle string 对产品计费的期限(例如,一次性、每月或每季度)。 Optional
subscriptionid string 与服务关联的订阅 ID。 Optional
status string 要将服务更改为的状态。 Optional
notes string 服务的管理员注释。 Optional
serviceusername string 服务用户名。 Optional
servicepassword string 服务密码。 Optional
overideautosuspend string 是否提供覆盖自动挂起(‘on’ or ‘off’)。 Optional
overidesuspenduntil string 更新服务的覆盖暂停日期。格式:Y-m-d Optional
ns1 string (仅限 VPS/专用服务器) Optional
ns2 string (仅限 VPS/专用服务器) Optional
dedicatedip string Optional
assignedips string (仅限 VPS/专用服务器) Optional
diskusage int 磁盘使用量(以 MB 为单位)。 Optional
disklimit int 以 MB 为单位的磁盘限制。 Optional
bwusage int 以 MB 为单位的带宽使用量。 Optional
bwlimit int 以兆字节为单位的带宽限制。 Optional
suspendreason string Optional
promoid int 要关联的促销 ID。 Optional
unset array 要取消设置的项目数组。可以是以下之一:‘domain’, ‘serviceusername’, ‘servicepassword’, ‘subscriptionid’、‘ns1’, ‘ns2’、‘dedicatedip’, ‘assignedips’, ‘notes’, or ‘suspendreason’ Optional
autorecalc bool 是否自动重新计算服务的循环数量(这将忽略任何传递的 $recurringamount)。 Optional
customfields string 自定义字段值的 Base64 编码序列化数组 - base64_encode(serialize(array(“1”=>“Yahoo”))); Optional
configoptions string Base64 编码的可配置选项字段值的序列化数组 - base64_encode(serialize(array(configoptionid => dropdownoptionid, XXX => array(‘optionid’ => YYY, ‘qty’ => ZZZ)))) - XXX 是可配置选项 - YYY 是在 tblhostingconfigoption.optionid 中找到的选项 ID - ZZZ 是您要用于该选项的数量 Optional

响应参数

参数 类型 说明
result string 操作结果:成功或错误
serviceid int 更新服务的 ID。

示例请求 (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' => 'UpdateClientProduct',
            // See https://developers.whmcs.com/api/authentication
            'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
            'password' => 'SECRET_OR_HASHED_PASSWORD',
            'serviceid' => '1',
            'status' => 'Terminated',
            'customfields' => base64_encode(serialize(array("1"=>"Yahoo"))),
            'configoptions' => base64_encode(serialize(array(configoptionid => dropdownoptionid, XXX => array('optionid' => YYY, 'qty' => ZZZ)))),
            'responsetype' => 'json',
        )
    )
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);

示例请求(本地 API)

$command = 'UpdateClientProduct';
$postData = array(
    'serviceid' => '1',
    'status' => 'Terminated',
    'customfields' => base64_encode(serialize(array("1"=>"Yahoo"))),
    'configoptions' => base64_encode(serialize(array(configoptionid => dropdownoptionid, XXX => array('optionid' => YYY, 'qty' => ZZZ)))),
);
$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later

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

示例响应 JSON

{
    "result": "success",
    "serviceid": "1"
}

错误响应

可能的错误条件响应包括:

  • 未找到服务 ID

相关用法


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