public function invoke($arrInput) { try { $strUrlHost = $arrInput["urlHost"]; $strAppName = $arrInput["appName"]; self::$_strPath = $arrInput["urlPath"]; $strActionName = $arrInput["actionName"]; $strUrl = $strUrlHost . "/" . $strAppName . "/" . self::$_strPath; //获取所有模块的名称 $strCurPath = dirname(__FILE__); $strParamConfName = "param_" . strtolower(str_replace("/", "_", $strActionName)); $strTestConfName = "test_" . strtolower(str_replace("/", "_", $strActionName)); $strParamConfPath = "conf/app/{$strAppName}/{$strParamConfName}.conf"; $strTestConfPath = "conf/app/{$strAppName}/{$strTestConfName}.conf"; $arrRet["errno"] = Navilib_CommonError::SUCCESS; //解析参数配置 $arrParamConf = Bd_Conf::getAppConf($strParamConfName, $strAppName); if (false === ($arrUrlParam = self::_getUrlParam($arrParamConf, $strParamConfPath, $strAppName))) { $arrRet['data']['testResult'] = self::$_strResult; return Navilib_Utils::result($arrRet["errno"], $arrRet["data"]); } //var_dump($arrParamConf); //解析test配置 $arrTestConf = Bd_Conf::getAppConf($strTestConfName, $strAppName); if (false === $arrTestConf) { self::_appendResult("测试配置文件" . $strTestConfPath . "不存在,将使用默认策略来进行测试", self::CONTENT_WARNING); //默认的配置是:call_type为post,errno为0 $arrTestConf = array('call_type' => 'post', 'result' => array('errno' => 0)); } if (isset($arrTestConf["call_type"])) { self::$_strCallType = strtolower($arrTestConf["call_type"]); } self::_appendResult("使用" . self::$_strCallType . "方式请求" . $strUrl . "?" . http_build_query($arrUrlParam)); $strType = self::$_strCallType; if ("post" === self::$_strCallType) { $strType = true; } elseif ("get" === self::$_strCallType) { $strType = false; } //通过fetchurl访问url $str = Navilib_NetUtil::getUrlContent($strUrl, $arrUrlParam, $strType); $mixData = json_decode($str, true); //检查结果 self::_checkTest($mixData, $arrTestConf["result"]); if (true === self::$_bolTestRet) { self::_appendResult("测试通过"); } else { self::_appendResult("测试未通过", self::CONTENT_FATAL); } $arrRet['data']['testResult'] = self::$_strResult; return Navilib_Utils::result($arrRet["errno"], $arrRet["data"]); } catch (Exception $e) { Bd_Log::warning($e->getMessage(), $e->getCode()); return Navilib_Utils::result($e->getCode(), array()); } }
public function invoke($arrInput) { //用于登录 $params = $arrInput['data']; $params = json_decode(base64_decode($params), true); $url = Bd_Conf::getAppConf('intelligence/url'); $ret = Navilib_NetUtil::getUrlContent($url, $params); $ret = $ret ? json_decode($ret, true) : false; $return = array('errno' => 0, 'errmsg' => 'success'); if ($ret['errno'] !== 0) { $return['errno'] = 1; $return['errmsg'] = '通知情报系统失败'; } return $return; }
public function invoke($arrInput) { try { $strUrl = $arrInput["url"]; $strCallType = $arrInput["callType"]; $strUrlParam = $arrInput["urlParam"]; $arrUrlParam = json_decode($strUrlParam, true); $arrUrlParam["ignoreLogin"] = 1; $arrRet["errno"] = Navilib_CommonError::SUCCESS; $strType = "post" === $strCallType ? true : false; //通过fetchurl访问url $str = Navilib_NetUtil::getUrlContent($strUrl, $arrUrlParam, $strType); $mixData = json_decode($str, true); $arrRet["data"] = $mixData; return Navilib_Utils::result($arrRet["errno"], $arrRet["data"]); } catch (Exception $e) { Bd_Log::warning($e->getMessage(), $e->getCode()); return Navilib_Utils::result($e->getCode(), array()); } }
public function invoke($arrInput) { try { $strUrlHost = $arrInput["urlHostForCurlProxy"]; $strAppName = $arrInput["appNameForCurlProxy"]; $strActionInfo = $arrInput["actionInfoForCurlProxy"]; $strCallType = $arrInput["callTypeForCurlProxy"]; $strType = "post" === $strCallType ? true : false; $arrActionInfo = explode("##", $strActionInfo); $strPath = $arrActionInfo[0]; $strUrl = $strUrlHost . "/" . $strAppName . "/" . $strPath; //解析出待发起请求的所有参数 $arrUrlParam = array(); //$arrUrlParam["ignoreLogin"] = 1; foreach ($_POST as $strKey => $strVal) { if ($strKey !== 'urlHostForCurlProxy' && $strKey !== 'appNameForCurlProxy' && $strKey !== 'actionInfoForCurlProxy' && $strKey !== 'callTypeForCurlProxy' && $strKey !== 'paramTypeForCurlProxy' && $strKey !== 'signCodeForCreateSign') { $arrUrlParam[$strKey] = $strVal; } } foreach ($_FILES as $strKey => $arrItem) { $arrUrlParam[$strKey] = '@' . $arrItem['tmp_name']; $strType = 'upload'; } $arrRet["errno"] = Navilib_CommonError::SUCCESS; //通过fetchurl访问url $str = Navilib_NetUtil::getUrlContent($strUrl, $arrUrlParam, $strType); $mixData = json_decode($str, true); if (!empty($mixData)) { $mixData = self::_buildHtmlOutput($mixData); } else { $mixData = $str; } $arrRet["data"] = $mixData; return Navilib_Utils::result($arrRet["errno"], $arrRet["data"]); } catch (Exception $e) { Bd_Log::warning($e->getMessage(), $e->getCode()); return Navilib_Utils::result($e->getCode(), array()); } }
/** * @param $url * @return mixed **/ public static function shortUrl($url) { $data['url'] = $url; $api = Bd_Conf::getAppConf('shortapi/url'); $strRes = Navilib_NetUtil::getUrlContent($api, $data, 'post'); // $strRes = self::postData($api, $data, null); $arrResponse = json_decode($strRes, true); if (isset($arrResponse['tinyurl'])) { return $arrResponse['tinyurl']; } return false; }