...
|
...
|
@@ -155,10 +155,10 @@ class Yohobuy |
|
|
$urlBack = $url;
|
|
|
|
|
|
if (USE_INTER_FACE_SHUNT) {
|
|
|
if (strpos($url, API_URL)) {
|
|
|
if (strpos($url, API_URL) !== false) {
|
|
|
$isApi = true;
|
|
|
$url = self::_getUrl($url, $data);
|
|
|
} else if (strpos($url, SERVICE_URL)) {
|
|
|
} else if (strpos($url, SERVICE_URL) !== false) {
|
|
|
$isService = true;
|
|
|
$url = self::_getUrl($url, $data);
|
|
|
}
|
...
|
...
|
@@ -180,7 +180,7 @@ class Yohobuy |
|
|
$url = self::httpBuildQuery($url, $data);
|
|
|
} //echo $url;
|
|
|
|
|
|
UdpLog::debug('get shut api', $url);
|
|
|
// UdpLog::debug('get shut api', $url);
|
|
|
|
|
|
/* 开启缓存的情况 */
|
|
|
if ($cache && USE_CACHE) {
|
...
|
...
|
@@ -212,10 +212,9 @@ class Yohobuy |
|
|
}
|
|
|
|
|
|
$result = curl_exec($ch);
|
|
|
$httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
|
|
|
|
|
|
//如果分流执行失败,则走原来的逻辑
|
|
|
if (USE_INTER_FACE_SHUNT && $httpCode !== 200) {
|
|
|
if (USE_INTER_FACE_SHUNT && curl_getinfo($ch,CURLINFO_HTTP_CODE) !== 200) {
|
|
|
curl_close($ch);
|
|
|
return self::_get($urlBack, $data, $cache, $returnJson, $timeout, $userAgent, $useGzip);
|
|
|
}
|
...
|
...
|
@@ -279,7 +278,6 @@ class Yohobuy |
|
|
UdpLog::debug('call api: ', $url);
|
|
|
|
|
|
$result = curl_exec($ch);
|
|
|
$httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
|
|
|
if (!$returnJson && !empty($result)) {
|
|
|
$result = json_decode($result, true);
|
|
|
}
|
...
|
...
|
@@ -319,10 +317,10 @@ class Yohobuy |
|
|
$urlBack = $url;
|
|
|
|
|
|
if (USE_INTER_FACE_SHUNT) {
|
|
|
if (strpos($url, API_URL)) {
|
|
|
if (strpos($url, API_URL) !== false) {
|
|
|
$isApi = true;
|
|
|
$url = self::_getUrl($url, $data);
|
|
|
} else if (strpos($url, SERVICE_URL)) {
|
|
|
} else if (strpos($url, SERVICE_URL) !== false) {
|
|
|
$isService = true;
|
|
|
$url = self::_getUrl($url, $data);
|
|
|
}
|
...
|
...
|
@@ -372,12 +370,8 @@ class Yohobuy |
|
|
}
|
|
|
$result = curl_exec($ch);
|
|
|
|
|
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
|
|
|
|
UdpLog::debug('post api', array('url' => $url, 'httpCode' => $httpCode));
|
|
|
|
|
|
//如果分流执行失败,则走原来的逻辑
|
|
|
if (USE_INTER_FACE_SHUNT && $httpCode !== 200) {
|
|
|
if (USE_INTER_FACE_SHUNT && curl_getinfo($ch, CURLINFO_HTTP_CODE) !== 200) {
|
|
|
curl_close($ch);
|
|
|
return self::_post($urlBack, $data, $returnJson, $timeout, $header, $cookie);
|
|
|
}
|
...
|
...
|
@@ -708,11 +702,9 @@ class Yohobuy |
|
|
return false;
|
|
|
}
|
|
|
|
|
|
|
|
|
UdpLog::debug('read memcache');
|
|
|
$interfaceShunt = Cache::getBy('INTERFACE_SHUT_KEY', 'master');
|
|
|
|
|
|
UdpLog::debug('read memcahe: ', $interfaceShunt);
|
|
|
// UdpLog::debug('read memcahe: ', $interfaceShunt);
|
|
|
if (empty($interfaceShunt)) {
|
|
|
return false;
|
|
|
}
|
...
|
...
|
@@ -761,7 +753,7 @@ class Yohobuy |
|
|
}
|
|
|
|
|
|
$paseUrl = parse_url($url);
|
|
|
if (strpos($url, API_URL)) {
|
|
|
if (strpos($url, API_URL) !== false) {
|
|
|
|
|
|
if (empty($ips['api.yoho.cn'])) {
|
|
|
return false;
|
...
|
...
|
@@ -775,7 +767,7 @@ class Yohobuy |
|
|
|
|
|
$url = 'http://' . $ips['api.yoho.cn'][$num]['ip'] . rtrim($paseUrl['path'], '/') . '/';
|
|
|
|
|
|
} else if (strpos($url, SERVICE_URL)) {
|
|
|
} else if (strpos($url, SERVICE_URL) !== false) {
|
|
|
|
|
|
if (empty($ips['service.yoho.cn'])) {
|
|
|
return false;
|
...
|
...
|
|