當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


PHP WHMCS GetTicket用法及代碼示例

獲取特定票證

請求參數

參數 類型 說明 必需的
action string “GetTicket” Required
ticketnum string 用於查找票證的特定客戶票證號。 Optional
ticketid int 用於查找票證的特定票證 ID(需要 $ticketnum 或 $ticketid)。 Optional
repliessort string ASC 或 DESC。用於組織工單回複的順序。 Optional

響應參數

參數 類型 說明
result string 操作結果:成功或錯誤
ticketid int 工單的唯一 ID。
tid string 向最終用戶顯示的唯一票號字符串。
c string 票證的客戶端唯一訪問權限。
deptid int 工單所屬部門的 ID。
deptname string 工單所屬部門的名稱。
userid int 工單所屬的用戶 ID。
contactid int 打開工單的聯係人 ID。
name string 票證提交者的姓名。
email string 票證提交者的電子郵件。
requestor_name string 票證提交者的姓名。
requestor_type string 工單提交者的類型。
requestor_email string 票證提交者的電子郵件。
cc string 工單的抄送電子郵件地址。
date string 開票日期。格式:Y-m-d H:i:s
subject string 票的主題。
status string 工單的狀態。
priority string 票證的優先級。
admin string 打開工單的管理員用戶的名稱。
lastreply string 上次回複票證的日期。格式:Y-m-d H:i:s
flag int 票證標記到的管理員用戶的 ID。
service string 與票證關聯的服務的 ID(Sx 表示服務,Dx 表示域)。
replies array 工單上的一係列回複。
notes 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' => 'GetTicket',
            // See https://developers.whmcs.com/api/authentication
            'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
            'password' => 'SECRET_OR_HASHED_PASSWORD',
            'ticketid' => '1',
            'responsetype' => 'json',
        )
    )
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);

示例請求(本地 API)

$command = 'GetTicket';
$postData = array(
    'ticketid' => '1',
);
$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later

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

示例響應 JSON

{
    "result": "success",
    "ticketid": "1",
    "tid": "516757",
    "c": "KPqH7yG3",
    "deptid": "1",
    "deptname": "Sample Support Department",
    "userid": "1",
    "contactid": "0",
    "name": "Cynthia Reilly",
    "email": "[email protected]",
    "cc": "",
    "date": "2016-01-01 06:26:29",
    "subject": "This is a sample ticket",
    "status": "Closed",
    "priority": "Medium",
    "admin": "",
    "lastreply": "2016-01-01 06:30:16",
    "flag": "0",
    "service": "",
    "replies": {
        "reply": [
            {
                "replyid": "0",
                "userid": "1",
                "contactid": "0",
                "name": "Cynthia Reilly",
                "email": "[email protected]",
                "requestor_name": "Cynthia Reilly",
                "requestor_email": "[email protected]",
                "requestor_type": "Owner",
                "date": "2016-01-01 06:26:29",
                "message": "Hey, \r\n\r\nThis is the first ticket message!\r\n\r\nThanks\r\n\r\nCynthia",
                "attachment": "123456_attachment_name.png",
                "attachments": [
                    {
                        "filename": "attachment_name.png",
                        "index": 0
                    }
                ],
                "attachments_removed": true,
                "admin": ""
            },
            {
                "replyid": "1",
                "userid": "1",
                "contactid": "0",
                "name": "",
                "email": "",
                "requestor_name": "Demo Admin",
                "requestor_email": "",
                "requestor_type": "Operator",
                "date": "2016-01-01 06:27:01",
                "message": "Hello, \r\n\r\nThis is the first ticket reply by an admin user!\r\n\r\nThanks\r\n\r\nDemo Admin",
                "attachment": "",
                "attachments": [
                    []
                ],
                "attachments_removed": false,
                "admin": "Demo Admin",
                "rating": "0"
            },
            {
                "replyid": "2",
                "userid": "1",
                "contactid": "0",
                "name": "",
                "email": "",
                "requestor_name": "Cynthia Reilly",
                "requestor_email": "[email protected]",
                "requestor_type": "Owner",
                "date": "2016-01-01 06:30:16",
                "message": "Hey, \r\n\r\nThis is a second reply!\r\n\r\nThanks\r\n\r\nCynthia",
                "attachment": "",
                "attachments": [
                    []
                ],
                "attachments_removed": false,
                "admin": "",
                "rating": "0"
            }
        ]
    },
    "notes": {
        "note": [
            {
                "noteid": "1",
                "date": "2016-01-01 06:26:42",
                "message": "This is a ticket note",
                "attachment": "",
                "attachments": [
                    []
                ],
                "attachments_removed": false,
                "admin": "Demo Admin"
            }
        ]
    }
}

相關用法


注:本文由純淨天空篩選整理自whmcs.com大神的英文原創作品 GetTicket。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。