检索符合提供条件的配置产品
注意:此 API 方法旨在用于构建自定义订单表格。因此,对于给定的产品,只会返回启用了“在订单上显示”设置的自定义字段。
请求参数
参数 | 类型 | 说明 | 必需的 |
---|---|---|---|
action | string | “GetProducts” | Required |
pid | int | string | 获取特定的产品 id 配置。可以是逗号分隔的 id 列表 |
gid | int | 检索特定组 ID 中的产品 | Optional |
module | string | 使用特定模块检索产品 | Optional |
响应参数
参数 | 类型 | 说明 |
---|---|---|
result | 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' => 'GetProducts',
// See https://developers.whmcs.com/api/authentication
'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
'password' => 'SECRET_OR_HASHED_PASSWORD',
'pid' => '1',
'responsetype' => 'json',
)
)
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
示例请求(本地 API)
$command = 'GetProducts';
$postData = array(
'pid' => '1',
);
$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later
$results = localAPI($command, $postData, $adminUsername);
print_r($results);
示例响应 JSON
{
"result": "success",
"totalresults": 1,
"products": {
"product": [
{
"pid": 1,
"gid": 1,
"type": "hostingaccount",
"name": "Best Hosting Plan",
"slug": "best-hosting-plan",
"product-url": "https:\/\/www.example.com\/whmcs\/product-group\/best-hosting-plan",
"description": "This is our best hosting plan, with all the bells and whistles.",
"module": "cpanel",
"paytype": "recurring",
"pricing": {
"USD": {
"prefix": "$",
"suffix": " USD",
"msetupfee": "0.00",
"qsetupfee": "0.00",
"ssetupfee": "0.00",
"asetupfee": "0.00",
"bsetupfee": "0.00",
"tsetupfee": "0.00",
"monthly": "25.99",
"quarterly": "-1.00",
"semiannually": "-1.00",
"annually": "-1.00",
"biennially": "-1.00",
"triennially": "-1.00"
}
},
"customfields": {
"customfield": [
{
"id": 2,
"name": "Secondary Contact",
"description": "Would you like to provide a secondary point of contact?",
"required": ""
}
]
},
"configoptions": {
"configoption": [
{
"id": 4,
"name": "MultiPHP Services",
"type": "3",
"options": {
"option": [
{
"id": 4,
"name": "Include MultiPHP Options",
"rawName": null,
"recurring": 0,
"required": null,
"pricing": {
"USD": {
"msetupfee": "0.00",
"qsetupfee": "0.00",
"ssetupfee": "0.00",
"asetupfee": "0.00",
"bsetupfee": "0.00",
"tsetupfee": "0.00",
"monthly": "2.99",
"quarterly": "0.00",
"semiannually": "0.00",
"annually": "0.00",
"biennially": "0.00",
"triennially": "0.00"
}
}
}
]
}
}
]
}
}
]
}
}
相关用法
- PHP WHMCS GetPromotions用法及代码示例
- PHP WHMCS GetProjects用法及代码示例
- PHP WHMCS GetProject用法及代码示例
- PHP WHMCS GetPermissionsList用法及代码示例
- PHP WHMCS GetPaymentMethods用法及代码示例
- PHP WHMCS GetPayMethods用法及代码示例
- PHP WHMCS GetTicketNotes用法及代码示例
- PHP WHMCS GetUsers用法及代码示例
- PHP WHMCS GetTLDPricing用法及代码示例
- PHP WHMCS GetToDoItemStatuses用法及代码示例
- PHP WHMCS GetCurrencies用法及代码示例
- PHP WHMCS GetStaffOnline用法及代码示例
- PHP WHMCS GetEmails用法及代码示例
- PHP WHMCS GetClientPassword用法及代码示例
- PHP WHMCS GetRegistrars用法及代码示例
- PHP WHMCS GetAutomationLog用法及代码示例
- PHP WHMCS GetQuotes用法及代码示例
- PHP WHMCS GetActivityLog用法及代码示例
- PHP WHMCS GetModuleQueue用法及代码示例
- PHP WHMCS GetTickets用法及代码示例
- PHP WHMCS GetInvoices用法及代码示例
- PHP WHMCS GetServers用法及代码示例
- PHP WHMCS GetSupportStatuses用法及代码示例
- PHP WHMCS GetHealthStatus用法及代码示例
- PHP WHMCS GetTicketAttachment用法及代码示例
注:本文由纯净天空筛选整理自whmcs.com大神的英文原创作品 GetProducts。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。