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


PHP WHMCS GetStats用法及代碼示例

獲取業務績效指標和統計數據。

請求參數

參數 類型 說明 必需的
action string “GetStats” Required
timeline_days int (可選)檢索時間線值的天數(最多 90 天)。 Optional

響應參數

參數 類型 說明
result string 操作結果:成功或錯誤
income_today float 今天的總收入
income_thismonth float 本月總收入
income_thisyear float 今年總收入
income_alltime float 總收入
orders_pending int 掛單數量
orders_today_cancelled int 今天取消的訂單數量
orders_today_pending int 當天日期的掛單數量
orders_today_fraud int 當天日期的欺詐訂單計數
orders_today_active int 當天日期的活躍訂單數
orders_today_total int 當天日期的訂單數
orders_yesterday_cancelled int 昨天日期的取消訂單數
orders_yesterday_pending int 昨天日期的掛單數量
orders_yesterday_fraud int 昨天日期的欺詐訂單計數
orders_yesterday_active int 昨天日期的活躍訂單數
orders_yesterday_total int 昨天日期的訂單數
orders_thismonth_total int 本月訂單數
orders_thisyear_total int 今年訂單數
tickets_allactive int 有效票數
tickets_awaitingreply int 等待回複票數
tickets_flaggedtickets int 標記給進行 api 調用的管理員用戶的票數
tickets_open int 打開狀態的票數
tickets_answered int 已回答狀態的票數
tickets_customerreply int 客戶回複狀態的票數
tickets_closed int 關閉狀態的票數
tickets_onhold int On Hold 狀態的票數
tickets_inprogress int 正在進行中的工單數量
cancellations_pending int 未決取消的計數
todoitems_due int 到期的待辦事項計數
networkissues_open int 計算開放網絡問題
quotes_valid int 有效引號的計數
staff_online int 在線員工人數
timeline_data int 如果在調用中指定了 $timeline_days,則各種指標的曆史每日計數。

示例請求 (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' => 'GetStats',
            // See https://developers.whmcs.com/api/authentication
            'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
            'password' => 'SECRET_OR_HASHED_PASSWORD',
            'timeline_days' => '7',
            'responsetype' => 'json',
        )
    )
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);

示例請求(本地 API)

$command = 'GetStats';
$postData = array(
    'timeline_days' => '7',
);
$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later

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

示例響應 JSON

{
    "result": "success",
    "income_today": "$5.95 USD",
    "income_thismonth": "$101.45 USD",
    "income_thisyear": "$485.21 USD",
    "income_alltime": "$2485.25 USD",
    "orders_pending": 7,
    "orders_today_cancelled": 1,
    "orders_today_pending": 2,
    "orders_today_fraud": 1,
    "orders_today_active": 4,
    "orders_today_total": 8,
    "orders_yesterday_cancelled": 1,
    "orders_yesterday_pending": 2,
    "orders_yesterday_fraud": 0,
    "orders_yesterday_active": 2,
    "orders_yesterday_total": 4,
    "orders_thismonth_total": 18,
    "orders_thisyear_total": 124,
    "tickets_allactive": 60,
    "tickets_awaitingreply": 5,
    "tickets_flaggedtickets": 3,
    "tickets_open": 3,
    "tickets_answered": 25,
    "tickets_customerreply": 2,
    "tickets_closed": 245,
    "tickets_onhold": 30,
    "tickets_inprogress": 0,
    "cancellations_pending": 1,
    "todoitems_due": 5,
    "networkissues_open": 0,
    "billableitems_uninvoiced": 1,
    "quotes_valid": 2,
    "staff_online": 1,
    "timeline_data": {
        "new_orders": {
            "2018-11-30": 8,
            "2018-11-29": 4,
            "2018-11-28": 3,
            "2018-11-27": 5,
            "2018-11-26": 7,
            "2018-11-25": 9,
            "2018-11-24": 2
        },
        "accepted_orders": {
            "2018-11-30": 4,
            "2018-11-29": 2,
            "2018-11-28": 3,
            "2018-11-27": 4,
            "2018-11-26": 5,
            "2018-11-25": 8,
            "2018-11-24": 2
        },
        "income": {
            "2018-11-30": "5.95",
            "2018-11-29": "10.17",
            "2018-11-28": "15.30",
            "2018-11-27": "18.90",
            "2018-11-26": "17.45",
            "2018-11-25": "10.28",
            "2018-11-24": "5.18"
        },
        "expenditure": {
            "2018-11-30": "0.00",
            "2018-11-29": "0.00",
            "2018-11-28": "0.00",
            "2018-11-27": "0.00",
            "2018-11-26": "0.00",
            "2018-11-25": "0.00",
            "2018-11-24": "0.00"
        },
        "new_tickets": {
            "2018-11-30": 5,
            "2018-11-29": 7,
            "2018-11-28": 10,
            "2018-11-27": 8,
            "2018-11-26": 4,
            "2018-11-25": 9,
            "2018-11-24": 12
        }
    }
}

相關用法


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