BrandData.php
5.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<?php
namespace LibModels\Web\Product;
use Api\Yohobuy;
use Api\Sign;
/**
* 品牌数据接口操作类
*
* @name BrandData
* @package Library/LibModels/wap/Category
* @copyright yoho.inc
* @version 1.0 (2015-10-10)
* @author gtskk <rocky.zhang@yoho.cn>
*/
class BrandData
{
const URI_BRAND_TOPPOS = 'operations/api/v5/resource/get';
const URL_BRAND_LOGO = 'cmsproduct/service/v1/brands';
const URL_BRAND_FOLDER = 'cmsproduct/service/v1/brands';
/**
* 获取品牌简介
*
* @param integer $brandId 品牌ID
* @param int 用户ID
* @return array 品牌介绍信息
*/
public static function getBrandIntro($brandId, $uid)
{
// 构建必传参数
$param = Yohobuy::param();
$param['brand_id'] = $brandId;
$param['uid'] = $uid;
$param['method'] = 'app.brand.getBrandIntro';
$param['client_secret'] = Sign::getSign($param);
$cache = empty($uid) ? 3600 : false;
return Yohobuy::get(API_URL, $param, $cache); // 有缓存1小时
}
/**
* 获取品牌banner图
* @param integer $brandId 品牌ID
* @return array banner图
*/
public static function getBrandBanner($brandId)
{
// 构建必传参数
$param = Yohobuy::param();
$param['brand_id'] = $brandId;
$param['method'] = 'app.brand.banner';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(API_URL, $param, 3600); // 有缓存1小时
}
/**
* 通过域名获取品牌LOGO信息
*
* @param int $domain 品牌domain
* @return array
*/
public static function getBrandLogoByDomain($domain)
{
$param = Yohobuy::param();
$param['domain'] = $domain;
$param['method'] = 'web.brand.byDomain';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(API_URL, $param, 600);
}
/**
* 通过品牌id获取品牌Folder
*
* @param int $brandId 品牌id
* @param int $status 状态
* @return array
*/
public static function getFolderByBrand($brandId, $status = 1)
{
$param = Yohobuy::param();
$param['brand_id'] = $brandId;
$param['status'] = $status;
$param['method'] = 'web.brand.folder';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(API_URL, $param, 600);
}
/**
* 通过品牌id获取品牌Folder
*
* @param int $brandId 品牌id
* @param int $status 状态
* @return array
*/
public static function getSeries($brandId, $status = 1)
{
$param = Yohobuy::param();
$param['brand_id'] = $brandId;
$param['status'] = $status;
$param['method'] = 'web.brand.series';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(API_URL, $param, 600);
}
/**
* 根据节点和运行模式选择静态内容
* @param $node 20141219-100447
* @param string $mode
* @return mixed
*/
public static function getByNodeContent($node, $mode = 'release')
{
$param = Yohobuy::param();
$param['mode'] = $mode;
$param['node'] = $node;
$param['method'] = 'web.html.content';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(API_URL, $param, 600);
}
/**
* 分开取数,品牌一览 顶部的轮翻广告及热门品牌数据-PC
* @param string $contentCode 获取广告资源需要的位置码
*/
public static function getBrandTopData($contentCode, $clientType = 'web')
{
/* 顶部的轮翻广告及热门品牌数据 */
$param = Yohobuy::param();
$param['content_code'] = $contentCode;
$param['client_type'] = $clientType;
$param['private_key'] = Yohobuy::$privateKeyList[$clientType];
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(SERVICE_URL . self::URI_BRAND_TOPPOS, $param);
}
/**
* 分开取数,获取品牌一览 "按字母'A-Z'分组的品牌列表数据"
* @param int $channel 频道标识 1:男,2:女,3:潮童,4:创意生活
*/
public static function getBrandListData($channel = 1)
{
// 构建必传参数
$param = Yohobuy::param();
$param['method'] = 'app.brand.brandlist';
if (is_numeric($channel)) {
$param['yh_channel'] = $channel;
}
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(API_URL, $param);
}
/**
* 获取品牌banner信息
*
* @param string $brandId
* @param boolean $isOnlyUrl 是否指返回链接
* @return array
*/
public static function getBannerInfo($brandId, $isOnlyUrl = false)
{
// 构建必传参数
$param = Yohobuy::param();
$param['method'] = 'web.brand.banner';
$param['brand_id'] = $brandId;
$param['client_secret'] = Sign::getSign($param);
if ($isOnlyUrl) {
return Yohobuy::httpBuildQuery(API_URL, $param);
}
return Yohobuy::get(API_URL, $param, 600);
}
/**
* 获取品牌信息
*
* @param array $ids
* @return array
*/
public static function getBrandInfoByIds($ids)
{
$param = Yohobuy::param();
$param['method'] = 'web.brand.info';
$param['ids'] = is_array($ids) ? implode(',', $ids) : intval($ids);
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(API_URL, $param);
}
}