function callOpenSystem($paramArr) { global $memc_obj; $url = isset($paramArr['requesturl']) ? array_shift($paramArr) : C('OPEN_SYS_URL'); $cachetime = isset($paramArr['cachetime']) ? array_shift($paramArr) : 0; $token = C('OPEN_SYS_TOKEN'); //用户token $strParam = array2http($paramArr) . "&sign=" . createSign($paramArr, $token); //生成签名,组织参数 $urls = $url . $strParam; //构造Url // echo $urls;exit; $cachekey = C('DB_PREFIX') . "callOpenSystem_" . md5($urls); if ($cachetime > 0 && ($result = $memc_obj->get($cachekey))) { return $result; } //连接超时自动重试3次 $cnt = 0; if ($paramArr['getOrPost'] == '2') { //POST方式 while ($cnt < 3 && ($result = @vita_get_url_content2($url . 'sign=' . createSign2($paramArr, $token), $paramArr)) === FALSE) { $cnt++; } } else { //GET方式 while ($cnt < 3 && ($result = @vita_get_url_content($urls)) === FALSE) { $cnt++; } } if (strpos($result, "[") > 0 && strpos($result, "[") < strpos($result, "{")) { $result = substr($result, strpos($result, "[")); } else { $result = substr($result, strpos($result, "{")); } $memc_obj->set($cachekey, $result, $cachetime); return $result; }
function callOpenSystem($paramArr) { global $memc_obj; $url = isset($paramArr['requesturl']) ? array_shift($paramArr) : C('OPEN_SYS_URL'); $cachetime = isset($paramArr['cachetime']) ? array_shift($paramArr) : 0; $token = C('OPEN_SYS_TOKEN'); //用户token if (!empty($paramArr['app_key'])) { //POST方式 $sign = createSign2($paramArr, $token); } else { $sign = createSign($paramArr, $token); } $strParam = array2http($paramArr) . "&sign=" . $sign; //生成签名,组织参数 $urls = $url . $strParam; //构造Url $cachekey = "om_callOpenSystem_" . md5($urls); if ($cachetime > 0 && ($result = $memc_obj->get($cachekey))) { return $result; } //连接超时自动重试3次 $cnt = 0; if (!empty($paramArr['app_key'])) { //POST方式 while ($cnt < 3 && ($result = @vita_get_url_content2($urls, $paramArr)) == FALSE) { $cnt++; } } else { //GET方式 while ($cnt < 3 && ($result = @vita_get_url_content($urls)) == FALSE) { $cnt++; } //added by andy 09.04 if (empty($result)) { $result = file_get_contents($urls); } } $memc_obj->set($cachekey, $result, $cachetime); return $result; }