1234567891011121314151617181920212223242526272829303132 |
- <?php
- namespace App\Services\Auth;
- use App\Facades\ChuanglanSmsFacade;
- use App\Services\Service;
- use Illuminate\Support\Facades\Cache;
- class PhoneService extends Service
- {
- /**
- * 发送短信验证码
- * @param string $phone
- * @return bool
- */
- public function sendVerifyCode(string $phone)
- {
- $code = rand(1000, 9999);
- $result = ChuanglanSmsFacade::sendSMS($phone, "【无邪科技】您的短信验证码为:{$code},若非本人操作请忽略。");
- if (isset($result['code']) && $result['code'] == '0') {
- Cache::put("smsverifycode:{$phone}", $code, 1);
- return true;
- }
- app('sentry')->captureMessage("验证码发送异常日志", array(), array('extra' => $result));
- return false;
- }
- }
|