| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace tw\async\tasks;
- use crmeb\repositories\ShortLetterRepositories;
- /**
- * 异步发短信
- */
- class AsyncSms extends Task
- {
- public function getCmd(): string
- {
- return 'sms';
- }
- protected function _exec(array $params)
- {
- return ShortLetterRepositories::send(true, $params['phone'], $params['data'], $params['template']);
- }
- /**
- * 接口
- *
- * @param string $phone 接收手机号
- * @param array $data 模板参数
- * @param string $template 模板代号 见 config/sms.php
- * @return bool
- */
- public static function push(string $phone, array $data, string $template): bool
- {
- $inst = new self();
- return $inst->put([
- 'phone' => $phone,
- 'data' => $data,
- 'template' => $template,
- ]);
- }
- }
|