_Account = $this->getKey($this->_apiCode); //验证是否具有访问这个接口的权限 if(!isset($this->_Account['CL_account']) || !isset($this->_Account['CL_password'])){ HelperService::returnJson(['code'=>400,'msg'=>'CLSMS interface unauthorized access','data'=>[]]); } } /** * 发送短信接口 */ public function sendMessage(){ $params = $this->_params; $rule = [ 'mobile|手机号'=>'require', 'message|短信内容'=>'require', ]; $validate = new Validate($rule); if(!$validate->check($params)){ HelperService::returnJson(['code'=>400,'msg'=>$validate->getError(),'data'=>[]]); } $CLSms = new CLSms($this->_Account['CHL_account'],$this->_Account['CHL_password']); $result = $CLSms->sendSMS($params['mobile'], $params['message']); $output = @json_decode($result,true); if($output){ if(isset($output['code']) && $output['code']=='0'){ HelperService::returnJson(['code'=>200,'msg'=>'发送成功','data'=>[]]); }else{ HelperService::returnJson(['code'=>400,'msg'=>$output['errorMsg'],'data'=>[]]); } } HelperService::returnJson(['code'=>400,'msg'=>'fail','data'=>$result]); } }