123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- declare(strict_types=1);
- namespace app\common\business;
- use AlibabaCloud\Client\Exception\ClientException;
- use app\common\lib\ClassArr;
- use app\common\lib\Num;
- use app\common\lib\sms\AliSms;
- class Sms
- {
- public static function sendCode(string $phoneNumber, int $len, string $type = 'ali'): bool
- {
-
- $code = Num::getCode($len);
-
-
-
-
-
-
-
- $classStats = ClassArr::smsClassStat();
- $class = ClassArr::initClass($type, $classStats);
- $sms = $class::sendCode($phoneNumber, $code);
- if ($sms) {
-
-
-
- cache(config('redis.code_pre') . $phoneNumber, $code, config('redis.expire'));
- }
- return true;
- }
- }
|