1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use app\common\model\Sms as smss;
- use think\facade\Validate;
- use think\Request;
- /**
- * @title 发送短信
- * @controller Sms
- */
- class Sms extends Api
- {
- /**
- * @title 发送短信
- * @desc 发送短信
- * @url /api/Sms/alsend
- * @method POST
- * @tag 基础
- * @header
- * @param name:phone type:string require:1 desc:手机号
- * @param name:event type:string require:0 desc:发送类型register:注册forgetpwd:修改密码login:登录changepwd:修改密码bindwechat:授权登录绑定
- */
- public function alsend()
- {
- $mobile = input("phone");
- $event = input("event",'register');
- if (!$mobile || !Validate::regex($mobile, "^1\d{10}$")) {
- $this->error('手机号不正确');
- }
- $result = smss::send_sms($mobile,$event);
- if ($result['code']){
- $this->success($result['msg'],$result['data']);
- }else{
- $this->error($result['msg']);
- }
- }
- }
|