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


PHP WHMCS GetActivityLog用法及代碼示例

獲取符合通過條件的活動日誌

請求參數

參數 類型 說明 必需的
action string “GetActivityLog” Required
limitstart int 返回的日誌數據的偏移量(默認值:0) Optional
limitnum int 返回的記錄數(默認:25) Optional
clientid int 要為其獲取日誌的客戶端的 ID。 Optional
date string 以本地化格式檢索的活動日誌的日期(例如 01/01/2016) Optional
user string 要檢索其日誌條目的用戶名 Optional
description string 在日誌中搜索特定字符串 Optional
ipaddress string 用於搜索活動日誌的 IP 地址 Optional

響應參數

參數 類型 說明
result string 操作結果:成功或錯誤
totalresults int 可用結果總數
startnumber int 返回結果的起始編號
activity 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' => 'GetActivityLog',
            // See https://developers.whmcs.com/api/authentication
            'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
            'password' => 'SECRET_OR_HASHED_PASSWORD',
            'description' => 'Cron Job',
            'responsetype' => 'json',
        )
    )
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);

示例請求(本地 API)

$command = 'GetActivityLog';
$postData = array(
    'description' => 'Cron Job',
);
$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later

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

示例響應 JSON

{
    "result": "success",
    "totalresults": 2,
    "startnumber": 0,
    "activity": {
        "entry": [
            {
                "id": 2,
                "clientId": 0,
                "userId": 0,
                "adminId": 1,
                "date": "2021-01-01 06:56:49",
                "description": "Cron Job: Check for Updates: No new updates available",
                "username": "admin",
                "ipaddress": "172.18.0.1",
                "userid": 0
            },
            {
                "id": 1,
                "clientId": 0,
                "userId": 0,
                "adminId": 1,
                "date": "2021-01-01 06:56:49",
                "description": "Cron Job: Perform WHMCS Update Check",
                "username": "admin",
                "ipaddress": "172.18.0.1",
                "userid": 0
            }
        ]
    }
}

相關用法


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