Authored by hf

modify api to yohobuy test env

framework @ 75bbc3b0
Subproject commit 119c247f5cf929aa1e059e40609bb16dd6b58f05
Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2
... ...
... ... @@ -4,7 +4,7 @@
* 所有Controller控制器的基类
*
* @name AbstractAction
* @package
* @package library
* @copyright yoho.inc
* @version 1.0 (2015-9-15 11:55:25)
* @author fei.hong <fei.hong@yoho.cn>
... ... @@ -41,13 +41,13 @@ class AbstractAction extends Controller_Abstract
// 设置环境变量
switch (APPLICATION_ENV) {
case 'production':
case 'production': // 生产
$this->_view->assign('rlsEnv', true);
break;
case 'testing':
case 'testing': // 测试
$this->_view->assign('testEnv', true);
break;
case 'develop':
case 'develop': // 开发
default:
$this->_view->assign('devEnv', true);
break;
... ... @@ -350,25 +350,25 @@ class AbstractAction extends Controller_Abstract
'textCn' => '男生',
'textEn' => 'BOYS',
'styleClass' => 'boys',
'url' => '/boys.html',
'url' => '/boys',
),
1 => array(
'textCn' => '女生',
'textEn' => 'GIRLS',
'styleClass' => 'girls',
'url' => '/girls.html',
'url' => '/girls',
),
2 => array(
'textCn' => '潮童',
'textEn' => 'KIDS',
'styleClass' => 'kids',
'url' => '/kids.html',
'url' => '/kids',
),
3 => array(
'textCn' => '创意生活',
'textEn' => 'LIFE STYLE',
'styleClass' => 'life',
'url' => '/life.html',
'url' => '/life',
),
4 => array(
'textCn' => '逛',
... ...
... ... @@ -9,15 +9,20 @@
* @version 1.0 (2015-9-30 16:42:51)
* @author fei.hong <fei.hong@yoho.cn>
*/
namespace Api;
use Plugin\Cache;
namespace Api;
class Yohobuy
{
const API_URL = 'http://api2.open.yohobuy.com/';
const SERVICE_URL = 'http://service.api.yohobuy.com/';
// /* 正式环境 */
// const API_URL = 'http://api2.open.yohobuy.com/';
// const SERVICE_URL = 'http://service.api.yohobuy.com/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
/* 测试环境 */
const API_URL = 'http://test2.open.yohobuy.com/';
const SERVICE_URL = 'http://test.service.api.yohobuy.com/';
const YOHOBUY_URL = 'http://www.yohobuy.com/';
/**
... ... @@ -101,18 +106,6 @@ class Yohobuy
*/
public static function get($url, $data = array(), $returnJson = false, $timeout = 5)
{
// // 代表是否开启缓存
// $useCache = $cache && isset($data['client_secret']);
//
// /* 先尝试获取一级缓存(master), 有数据则直接返回 */
// if ($useCache) {
// $key = md5($url . $data['client_secret']);
// $result = Cache::get($key, 'master');
// if (!empty($result)) {
// return $result;
// }
// }
// 销毁私钥参数
if (isset($data['private_key'])) {
unset($data['private_key']);
... ... @@ -132,18 +125,6 @@ class Yohobuy
curl_close($ch);
$data = array();
// /* 设置一级二级缓存 或 获取二级缓存(slave) */
// if ($useCache) {
// // 如果接口异常没数据返回,则获取二级缓存
// if (empty($result)) {
// $result = Cache::get($key, 'slave');
// }
// // 如果接口正常有数据返回,则设置数据缓存
// else {
// Cache::set($key, $result);
// }
// }
return $result;
}
... ... @@ -165,8 +146,7 @@ class Yohobuy
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
if (!empty($header)) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
}
else {
} else {
curl_setopt($ch, CURLOPT_HEADER, 0);
}
... ... @@ -242,8 +222,7 @@ class Yohobuy
do {
do {
$status = curl_multi_exec($mh, $running);
}
while ($status == CURLM_CALL_MULTI_PERFORM);
} while ($status == CURLM_CALL_MULTI_PERFORM);
if ($status != CURLM_OK) {
break;
... ... @@ -252,8 +231,7 @@ class Yohobuy
if ($running > 0) {
curl_multi_select($mh, 0.5);
}
}
while ($running);
} while ($running);
// 获取API接口响应的结果
foreach ($urlList as $name => $api) {
... ... @@ -322,6 +300,7 @@ class Yohobuy
YAR_OPT_CONNECT_TIMEOUT => $timeout
));
}
public static function yarConcurrentLoop($callback = null)
{
\Yar_Concurrent_Client::loop($callback);
... ...
<?php
namespace Configs;
/**
* 缓存配置文件
*/
class CacheConfig
{
const KEY_ACTION_INDEX_INDEX = 'key_action_index_index';
}
... ...
<?php
namespace LibModels\Wap\Category;
use Api\Yohobuy;
... ... @@ -15,6 +16,7 @@ use Api\Sign;
*/
class BrandData
{
/**
* 获取品牌数据
*
... ... @@ -26,7 +28,6 @@ class BrandData
{
// 构建必传参数
$param = Yohobuy::param();
$param['method'] = 'app.brand.brandlist';
$param['yh_channel'] = $channel;
$param['client_secret'] = Sign::getSign($param);
... ... @@ -43,11 +44,10 @@ class BrandData
{
// 构建必传参数
$param = Yohobuy::param();
$param['content_code'] = 'ce6ac059493ec26241a8cbe0bfa1b17a';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::SERVICE_URL.'operations/api/v5/resource/get', $param);
return Yohobuy::get(Yohobuy::SERVICE_URL . 'operations/api/v5/resource/get', $param);
}
/**
... ... @@ -60,8 +60,7 @@ class BrandData
{
// 构建必传参数
$param = Yohobuy::param();
$param['brand_id'] = '$brandId';
$param['brand_id'] = $brandId;
$param['method'] = 'app.brand.getBrandIntro';
$param['client_secret'] = Sign::getSign($param);
... ... @@ -77,8 +76,7 @@ class BrandData
{
// 构建必传参数
$param = Yohobuy::param();
$param['brand_id'] = '$brandId';
$param['brand_id'] = $brandId;
$param['method'] = 'app.brand.banner';
$param['client_secret'] = Sign::getSign($param);
... ... @@ -113,7 +111,9 @@ class BrandData
'p_d' => $p_d
);
// 拉取筛选参数
$queriedParams = array_filter($selectItems, function($v) {return $v !== null;});
$queriedParams = array_filter($selectItems, function($v) {
return $v !== null;
});
// 构建必传参数
$param = Yohobuy::param();
... ... @@ -126,4 +126,5 @@ class BrandData
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
... ... @@ -16,16 +16,14 @@ class BoysController extends AbstractAction
$this->setTitle('男生首页');
// 显示侧边栏
$this->setNavSide();
// 显示顶部下载
$this->setHeaderDownload();
// 设置顶部信息(搜索)
$this->setHomeChannelHeader();
$data = array('boysHomePage' => true);
$uid = $this->getUid();
// 频道数据
$channelData = IndexData::getUserChannelData(0, '1,3', '201504091403001');
$channelData = IndexData::getUserChannelData($uid, '1,3', '201504091403001');
if (isset($channelData['code']) && $channelData['code'] == 200) {
$data['content'] = FloorProcess::getContent($channelData['data']);
}
... ...
... ... @@ -16,16 +16,14 @@ class GirlsController extends AbstractAction
$this->setTitle('女生首页');
// 显示侧边栏
$this->setNavSide();
// 显示顶部下载
$this->setHeaderDownload();
// 设置顶部信息(搜索)
$this->setHomeChannelHeader();
$data = array('grilsHomePage' => true);
$uid = $this->getUid();
// 频道数据
$channelData = IndexData::getUserChannelData(0, '2,3', '201504091403002');
$channelData = IndexData::getUserChannelData($uid, '2,3', '201504091403002');
if (isset($channelData['code']) && $channelData['code'] == 200) {
$data['content'] = FloorProcess::getContent($channelData['data'], 2);
}
... ...
... ... @@ -15,8 +15,6 @@ class IndexController extends AbstractAction
*/
public function indexAction()
{
$data = array();
// 背景图获取
$banner = IndexData::getBannerStart();
if ($banner) {
... ... @@ -27,7 +25,7 @@ class IndexController extends AbstractAction
$this->setNavFooter();
// 生成HTML (index.html)
$this->_view->html('index');
// $this->_view->html('index');
// 渲染模板
$this->_view->display('index', $data);
... ...
... ... @@ -16,16 +16,14 @@ class KidsController extends AbstractAction
$this->setTitle('潮童首页');
// 显示侧边栏
$this->setNavSide();
// 显示顶部下载
$this->setHeaderDownload();
// 设置顶部信息(搜索)
$this->setHomeChannelHeader();
$data = array('kidsHomePage' => true);
$uid = $this->getUid();
// 频道数据
$channelData = IndexData::getUserChannelData(0, '', 'e9875682c1599a886bfbdb965b740022');
$channelData = IndexData::getUserChannelData($uid, '', 'e9875682c1599a886bfbdb965b740022');
if (isset($channelData['code']) && $channelData['code'] == 200) {
$data['content'] = FloorProcess::getContent($channelData['data'], 3);
}
... ...
... ... @@ -16,16 +16,14 @@ class LifestyleController extends AbstractAction
$this->setTitle('创意生活首页');
// 显示侧边栏
$this->setNavSide();
// 显示顶部下载
$this->setHeaderDownload();
// 设置顶部信息(搜索)
$this->setHomeChannelHeader();
$data = array('lifestyleHomePage' => true);
$uid = $this->getUid();
// 频道数据
$channelData = IndexData::getUserChannelData(0, '', '9aa25f5133f011ec96c2045eb15ae425');
$channelData = IndexData::getUserChannelData($uid, '', '9aa25f5133f011ec96c2045eb15ae425');
if (isset($channelData['code']) && $channelData['code'] == 200) {
$data['content'] = FloorProcess::getContent($channelData['data'], 4);
}
... ...
... ... @@ -107,9 +107,23 @@ class LoginController extends AbstractAction
/* 调用登录接口进行登录 */
$data = LoginData::signin($area, $profile, $password);
if ($data['code'] == 200) {
$data['data'] = '/'; // @todo
if ($data['code'] != 200 || !isset($data['data']['uid'])) {
break;
}
// /* 获取用户的信息 */
// $profile = LoginData::profile($data['data']['uid']);
// $name = 'YOHO!';
// if (!empty($profile['data']['nickname'])) {
// $name = $profile['data']['nickname'];
// } elseif (!empty($profile['data']['username'])) {
// $name = $profile['data']['username'];
// } elseif (!empty($profile['data']['email'])) {
// $name = $profile['data']['email'];
// } elseif (!empty($profile['data']['mobile'])) {
// $name = $profile['data']['mobile'];
// }
$data['data'] = '/'; // @todo
}
while (false);
... ...
... ... @@ -19,7 +19,7 @@ application.dispatcher.defaultController = "index"
application.dispatcher.defaultAction = "index"
;;初始化命名空间
application.namespaces = "Action,Api,LibModels,Plugin"
application.namespaces = "Action,Api,Configs,LibModels,Plugin"
;;使用composer
composer.autoload = 0
... ...
... ... @@ -19,7 +19,7 @@ application.dispatcher.defaultController = "index"
application.dispatcher.defaultAction = "index"
;;初始化命名空间
application.namespaces = "Action,Api,LibModels,Plugin"
application.namespaces = "Action,Api,Configs,LibModels,Plugin"
;;使用composer
composer.autoload = 0
... ...
... ... @@ -19,7 +19,7 @@ application.dispatcher.defaultController = "index"
application.dispatcher.defaultAction = "index"
;;初始化命名空间
application.namespaces = "Action,Api,LibModels,Plugin"
application.namespaces = "Action,Api,Configs,LibModels,Plugin"
;;使用composer
composer.autoload = 0
... ...
User-agent: *
Disallow: /
\ No newline at end of file
... ...