errorMsg; } /** * 发送短信 * @param $phone_num * @param $send_type * @return bool * @throws \End01here\EasySms\Exceptions\CodeErrorException * @throws \End01here\EasySms\Exceptions\GatewayErrorException * @throws \End01here\EasySms\Exceptions\MessageException */ function sendCode($phone_num,$send_type='default') { try { $phone = EasySmsService::getPhoneSever($phone_num); $code_server = EasySmsService::getCodeSever($phone)->setCode($send_type); $message_server = EasySmsService::getMessageServer(); $content = '您好,你的验证码:' . $code_server->getCode(); // $content = '您好,你的验证码:[var] ' ; $message_server->setContent($content); $send_info = EasySmsService::getSmsServer()->creatQybSms()->send($phone, $message_server); }catch (\Exception $e){ $this->errorMsg=$e->getMessage(); return false; } if (!empty($send_info['code']) && $send_info['code'] != 1) { $this->errorMsg = '短信发送失败'; return false; } return true; } /** * 验证码验证 * @param $phone_num * @param $code * @param $send_type * @return bool */ public function verifyCode($phone_num, $code,$send_type='default') { $phone = EasySmsService::getPhoneSever($phone_num); $code_sever= EasySmsService::getCodeSever($phone); $ret_code = $code_sever->verifyCode($code,$send_type); $this->errorMsg=$code_sever->getErrorMsg(); return $ret_code; } }