| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace app\api\controller;
- use app\api\service\TencentCloudService;
- use app\common\controller\Api;
- class Sms extends Api
- {
- protected $noNeedLogin = "*";
- public function send($mobile = null, $event = null)
- {
- if (!preg_match("/^1[23456789]\d{9}$/", $mobile))
- $this->error("手机号码错误!");
- if (!in_array($event, [
- "bind_mobile",//用户绑定手机
- "user_login",// 用户登录
- "user_cancel", // 用户注销账户
- "massager_login",//助教登录
- "agency_login", // 代理商登录
- "register", // 用户注册
- "reset_pwd", // 用户修改密码
- "massager_rest_pwd", // 助教修改密码
- "massager_modify_mobile", // 修改电话
- "massager_close_account", // 注销账户
- ]))
- $this->error("发送类型异常");
- $code = rand(1000, 9999);
- $valid = TencentCloudService::tencent_cloud_sms_send("2280835", $mobile, [$code]);
- if ($valid->code()) {
- \app\common\model\Sms::create(['event' => $event, 'mobile' => $mobile, 'code' => $code, 'ip' => request()->ip(), 'createtime' => time()]);
- $this->success(true);
- }
- $this->error($valid->msg());
- }
- // public function test_vms_send()
- // {
- // $valid = TencentCloudService::tencent_cloud_vms_send("15574920253", "1477072", "OAP" . time());
- // dump($valid);
- // }
- }
|