dd/app/Services/Cron/ReportTraffic.php
2026-08-11 11:00:00 +08:00

54 lines
1.4 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
declare(strict_types=1);
namespace App\Services\Cron;
//use App\Services\Cron;
//use App\Models\HttpQueue as ModelHttpQueue;
//use App\Services\TomTool\Telegram\Master as TelegramMaster;
//use App\Services\TomTool\Telegram\Slave as TelegramSlave;
//use App\Services\TomTool\HttpV2;
//use Telegram\Bot\Api;
//use Telegram\Bot\Exceptions\TelegramSDKException;
//use Telegram\Bot\Exceptions\TelegramSDKException;
//use Telegram\Bot\Exceptions\TelegramResponse;
use Illuminate\Support\Facades\Http;
final class ReportTraffic
{
public function all()
{
$this->umami();
}
public function umami()
{
$r = $this->umami_checkToken();
tt($r);
}
private function umami_checkToken()
{
$oResponse = Http::post('https://api.umami.is/api/auth/login', [
'username' => "ad1473af-2b82-4e9b-a726-36bef6cc512b",
'password' => "UOtaonihouzi123#",
]);
// 工业级防御:非 2xx 响应直接抛出 Http 异常
$oResponse->throw();
// 解析 JSON
$aData = $oResponse->json();
// 检查 Key 是否符合预期(假设返回结构为 {"token": "xxx"}
if (empty($aData['token'])) {
throw new Exception('接口响应格式有误:缺失 token 字段');
}
return $aData['token'];
}
}