Sms.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use app\common\model\Sms as smss;
  5. use think\facade\Validate;
  6. use think\Request;
  7. /**
  8. * @title 发送短信
  9. * @controller Sms
  10. */
  11. class Sms extends Api
  12. {
  13. /**
  14. * @title 发送短信
  15. * @desc 发送短信
  16. * @url /api/Sms/alsend
  17. * @method POST
  18. * @tag 基础
  19. * @header
  20. * @param name:phone type:string require:1 desc:手机号
  21. * @param name:event type:string require:0 desc:发送类型register:注册forgetpwd:修改密码login:登录changepwd:修改密码bindwechat:授权登录绑定
  22. */
  23. public function alsend()
  24. {
  25. $mobile = input("phone");
  26. $event = input("event",'register');
  27. if (!$mobile || !Validate::regex($mobile, "^1\d{10}$")) {
  28. $this->error('手机号不正确');
  29. }
  30. $result = smss::send_sms($mobile,$event);
  31. if ($result['code']){
  32. $this->success($result['msg'],$result['data']);
  33. }else{
  34. $this->error($result['msg']);
  35. }
  36. }
  37. }