Ejemplo n.º 1
0
 /**
  * 发送短信验证码
  * @author Hanxiang
  */
 public function sendSmsCode()
 {
     $input = Input::all();
     $validator = Validator::make($input, ['mobile' => 'required']);
     if ($validator->fails()) {
         return $this->sendResponse(20101, $validator->messages()->first());
     }
     if (!preg_match('/^[1][34578]\\d{9}$/', $input['mobile'])) {
         return $this->sendResponse(20102, 'mobile invalid');
     }
     $code = mt_rand(1000, 9999);
     $check = SmsCode::checkMobile($input['mobile'], $code);
     if (!$check) {
         return $this->sendResponse(20103, 'please retry after 30s');
     }
     Yunpian::sendSmsCode($input['mobile'], $code);
     return $this->sendResponse(10000, 'success');
 }