isEnabled('elisoftsms')) { throw new \Exception('未开启验证码,请联系管理员!'); } $setting = SystemSetting::settingLoad('sms', 'system_sms'); $code = $this->getCode($mobile,$this->key); $msg = '【' . $this->sms['elisoft_signname'] . '】' . '您的验证码是:' . $code . '。请不要把验证码泄露给其他人。如非本人操作,可不用理会!'; $account = $this->sms['elisoft_account']; $passward = $this->sms['elisoft_password']; if($setting['interior_sms_type']==1){ $param = [ 'c' => urlencode($msg), 'p' => $mobile, ]; $sms = new \Yunshop\Elisoftsms\services\ElisoftSmsService($account,$passward); $res = $sms->setAction('sendbatch')->send($param); if ($res['result'] != 1) { throw new \Exception($res['errormsg']); } }else{ $msgArr=[ '-1'=>'Uid或密码为空', '-2'=>'下发号码为空', '-3'=>'下发内容为空', '-4'=>'内容超长', '-5'=>'下发号码超长', '-6'=>'uid或密码不正确', '-7'=>'短信余额不足', '-8'=>'IP地址鉴权不对', '-9'=>'协议类型不对', '-99'=>'系统异常' ]; $url="http://3qdx.com:18002/send.do"; $param=['uid'=>$setting['klws_account'],'pw'=>md5($setting['klws_password'].date('YmdHis')),'mb'=>$mobile,'tm'=>date('YmdHis'),'ms'=>$msg]; $url=$url.'?'.http_build_query($param); $client = new Client(); $res=$client->get($url)->getBody()->getContents(); if (in_array($res,['-1','-2','-3','-4','-5','-6','-7','-8','-9','-99'])) { throw new \Exception($res); } } return true; } catch (\Exception $e) { \Log::debug('elisoftsms短信'.$e->getMessage(),[isset($res)?$res:'',isset($param)?$param:'']); return $e->getMessage(); } } }