get('sms'); if(empty($options)){ throw new \ErrorException('短信配置错误'); } $post = [ 'phonenumbers' => $mobile, 'signname' => $signname, 'templatecode' => $templatecode, 'templateparam' => $templateparam, ]; $result = request($options['api_url'], $post); if( $result['httpcode'] == 200 && !empty($result['content'])){ $resultContent = json_decode($result['content'],true); if($resultContent['state']){ return ResultWrapper::success('发送成功'); }else{ return ResultWrapper::fail($resultContent['data'], ErrorCode::$apiNotResult); } }else{ if(!empty($result['content'])){ file_put_contents('/tmp/sendSms.log',date('Y-m-d H:i:s').var_export($result['content'],true).PHP_EOL,FILE_APPEND); return ResultWrapper::fail('请求接口失败,错误原因请留意日志', ErrorCode::$apiNotResult); }else{ return ResultWrapper::fail('发送失败,接口未返回消息', ErrorCode::$apiNotResult); } } } public function getError() { return $this->error; } }