| 1234567891011121314151617181920212223242526272829303132 |
- <?php
- namespace App\Jobs;
- use App\Repositories\ConfigRepoistory;
- use App\Repositories\Service\CommonService;
- use Hyperf\AsyncQueue\Job;
- class PublicSendTgMegJob extends Job
- {
- public $routes;
- public function __construct($params)
- {
- // 这里最好是普通数据,不要使用携带 IO 的对象,比如 PDO 对象
- $this->params = $params;
- }
- public function handle()
- {
- $configRepo = make(ConfigRepoistory::class);
- $tgMsgServer = $configRepo->get('tg_msg_server', 'sys', '');
- $tgApiToken = $configRepo->get('tg_api_token', 'sys', '');
- if ($tgMsgServer && $tgApiToken) {
- make(CommonService::class)->httpPostJson(
- $tgMsgServer . $this->params['routes'],
- // json_encode($this->params['content'], JSON_UNESCAPED_UNICODE),
- $this->params['content'],
- ['AUTH-TOKEN' => $tgApiToken]);
- }
- }
- }
|