Sms.php 586 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. /**
  3. * Created by PhpStorm
  4. * User: 林志杰
  5. * Email: [email protected]
  6. * Time: 2020/1/11 17:56
  7. */
  8. declare(strict_types=1);
  9. namespace app\common\business;
  10. use AlibabaCloud\Client\Exception\ClientException;
  11. use app\common\lib\sms\AliSms;
  12. class Sms
  13. {
  14. public static function sendCode(string $phoneNumber): bool
  15. {
  16. // 生成短信验证码
  17. $code = random_int(100000, 999999);
  18. $sms = AliSms::sendCode($phoneNumber, $code);
  19. if ($sms) {
  20. // 将验证码记录到redis,并设置失效时间
  21. }
  22. return true;
  23. }
  24. }