添加客户端。
请求参数
参数 | 类型 | 说明 | 必需的 |
---|---|---|---|
action | string | “AddClient” | Required |
owner_user_id | int | 应该拥有客户端的用户的 ID。可选的。如果未提供,将创建一个新用户。 | Optional |
firstname | string | 要创建的客户的名字。当未指定owner_user_id 时,也用于用户的名字。 |
Required |
lastname | string | 要创建的客户的姓氏。当未指定owner_user_id 时,也用于用户的姓氏。 |
Required |
companyname | string | Optional | |
string | 要创建的客户的电子邮件地址。当未指定owner_user_id 时,也用于用户的电子邮件。 |
Required | |
address1 | string | Required | |
address2 | string | Optional | |
city | string | Required | |
state | string | Required | |
postcode | string | Required | |
country | string | 2 个字符的 ISO 国家代码。 | Required |
phonenumber | string | Required | |
tax_id | string | 客户的税号。 | Optional |
password2 | string | 新创建的用户帐户的密码。未指定 owner_user_id 时需要。 |
Optional |
securityqid | int | tbladminsecurityquestions 中安全问题的 ID。未指定 owner_user_id 时需要。 |
Optional |
securityqans | string | 新创建用户的安全问题答案。 | Optional |
currency | int | 来自 tblcurrencies 的货币 ID。 |
Optional |
groupid | int | 来自 tblclientgroups 的客户端组 ID。 |
Optional |
customfields | string | Base64 编码的自定义字段值的序列化数组。 | Optional |
language | string | 默认语言设置。当未指定owner_user_id 时,也用于用户的语言。提供全名:‘english’, ‘french’,等等……。 |
Optional |
clientip | string | 请求的原始 IP 地址。 | Optional |
notes | string | 仅管理员注释。 | Optional |
marketingoptin | bool | 客户是否应该opt-in 来接收营销电子邮件。 | Optional |
noemail | bool | 是否向客户发送欢迎电子邮件。真正的值不会发送电子邮件。 | Optional |
skipvalidation | bool | 是否强制执行必填字段。真值不会强制执行必填字段。当未指定owner_user_id 时,这不适用于email 和password2 。 |
Optional |
Deprecated | |||
Deprecated | |||
Deprecated | |||
Deprecated | |||
Deprecated | |||
Deprecated |
响应参数
参数 | 类型 | 说明 |
---|---|---|
result | 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' => 'AddClient',
// See https://developers.whmcs.com/api/authentication
'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
'password' => 'SECRET_OR_HASHED_PASSWORD',
'firstname' => 'John',
'lastname' => 'Doe',
'email' => '[email protected]',
'address1' => '123 Main Street',
'city' => 'Anytown',
'state' => 'State',
'postcode' => '12345',
'country' => 'US',
'phonenumber' => '800-555-1234',
'password2' => 'password',
'clientip' => '1.2.3.4',
'responsetype' => 'json',
)
)
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
示例请求(本地 API)
$command = 'AddClient';
$postData = array(
'firstname' => 'John',
'lastname' => 'Doe',
'email' => '[email protected]',
'address1' => '123 Main Street',
'city' => 'Anytown',
'state' => 'State',
'postcode' => '12345',
'country' => 'US',
'phonenumber' => '800-555-1234',
'password2' => 'password',
'clientip' => '1.2.3.4',
);
$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later
$results = localAPI($command, $postData, $adminUsername);
print_r($results);
示例响应 JSON
{
"result": "success",
"clientid": "1"
}
警告响应
使用已删除或标记为已弃用的 API 函数时会返回警告响应。我们建议遵循警告中的任何建议操作,以确保未来的兼容性。
可能的警告消息包括:
- 信用卡相关参数现已弃用,可能会在未来版本中删除。请改用AddPayMethod。
错误响应
可能的错误条件响应包括:
- 所有者用户 ID 无效
- 你没有输入你的名字
- 你没有输入你的姓氏
- 您没有输入您的电子邮件地址
- 您输入的电子邮件地址无效
- 您没有输入您的电子邮件地址
- 您没有输入您的地址第 1 行
- 你没有进入你的城市
- 你没有进入你的州
- 您没有输入邮政编码
- 需要有效的国家
- 你没有输入你的电话号码
- 电话号码无效
- 您没有提供所需的自定义字段值
- 使用该电子邮件地址的客户已经存在
- 已存在使用该电子邮件地址的用户
相关用法
- PHP WHMCS AddClientNote用法及代码示例
- PHP WHMCS AddContact用法及代码示例
- PHP WHMCS AddCancelRequest用法及代码示例
- PHP WHMCS AddCredit用法及代码示例
- PHP WHMCS AddonUnsuspended用法及代码示例
- PHP WHMCS AddUser用法及代码示例
- PHP WHMCS AddonAdd用法及代码示例
- PHP WHMCS AddonTerminated用法及代码示例
- PHP WHMCS AddPayMethod用法及代码示例
- PHP WHMCS AddBillableItem用法及代码示例
- PHP WHMCS AddonFraud用法及代码示例
- PHP WHMCS AddTransaction用法及代码示例
- PHP WHMCS AddonDeleted用法及代码示例
- PHP WHMCS AddonActivated用法及代码示例
- PHP WHMCS AddOrder用法及代码示例
- PHP WHMCS AddonSuspended用法及代码示例
- PHP WHMCS AddInvoicePayment用法及代码示例
- PHP WHMCS AddAnnouncement用法及代码示例
- PHP WHMCS AddonConfigSave用法及代码示例
- PHP WHMCS AddonConfig用法及代码示例
- PHP WHMCS AddBannedIp用法及代码示例
- PHP WHMCS AddonRenewal用法及代码示例
- PHP WHMCS AddProjectTask用法及代码示例
- PHP WHMCS AddTicketNote用法及代码示例
- PHP WHMCS AddProjectMessage用法及代码示例
注:本文由纯净天空筛选整理自whmcs.com大神的英文原创作品 AddClient。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。