src/Biz/Common/BizSms.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Biz\Common;
use AppBundle\Common\TimeMachine;
use Codeages\Biz\Framework\Context\BizAware;
class BizSms extends BizAware
{
const STATUS_SUCCESS = 'sms.code.success';
const STATUS_INVALID = 'sms.code.invalid';
const STATUS_EXPIRED = 'sms.code.expired';
const SMS_BIND_TYPE = 'sms_bind';
const SMS_REGISTER = 'sms_registration';
const SMS_FORGET_PASSWORD = 'sms_forget_password';
public function send($smsType, $mobile, $options = array())
{
$options = array_merge(array('duration' => TimeMachine::HALF_HOUR, 'times' => 10, 'userId' => 0), $options);
$result = $this->getSmsService()->sendVerifySms($smsType, $mobile, 0);
$smsToken = $this->getTokenService()->makeToken($smsType, array(
'times' => $options['times'],
'duration' => $options['duration'],
'userId' => $options['userId'],
'data' => array(
'code' => $result['captcha_code'],
'mobile' => $mobile,
),
));
return $smsToken;
}
public function check($smsType, $mobile, $smsToken, $code)
{
$token = $this->getTokenService()->verifyToken($smsType, $smsToken);
if (empty($token)) {
return self::STATUS_INVALID;
}
$remainedTimes = $token['remainedTimes'];
if (0 == $remainedTimes) {
return self::STATUS_EXPIRED;
}
if ($token['data']['code'] !== $code || $token['data']['mobile'] !== $mobile) {
return self::STATUS_INVALID;
}
return self::STATUS_SUCCESS;
}
/**
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。