Merge branch 'hotfix/couponapi'
Showing
1 changed file
with
44 additions
and
1 deletions
@@ -14,6 +14,8 @@ use Api\Yohobuy; | @@ -14,6 +14,8 @@ use Api\Yohobuy; | ||
14 | class CouponData | 14 | class CouponData |
15 | { | 15 | { |
16 | 16 | ||
17 | +// const API_URL = 'http://api.open.yohobuy.com/'; | ||
18 | + | ||
17 | /** | 19 | /** |
18 | * 获取领券楼层数据 | 20 | * 获取领券楼层数据 |
19 | * | 21 | * |
@@ -23,7 +25,7 @@ class CouponData | @@ -23,7 +25,7 @@ class CouponData | ||
23 | */ | 25 | */ |
24 | public static function getCouponRousource($contentCode, $uid) | 26 | public static function getCouponRousource($contentCode, $uid) |
25 | { | 27 | { |
26 | - $param = Yohobuy::param(); | 28 | + $param = self::param(); |
27 | $param['method'] = 'app.promotion.queryCouponCenter'; | 29 | $param['method'] = 'app.promotion.queryCouponCenter'; |
28 | $param['contentCode'] = $contentCode; | 30 | $param['contentCode'] = $contentCode; |
29 | if (!empty($uid) && $uid !== '' && $uid !== null) { | 31 | if (!empty($uid) && $uid !== '' && $uid !== null) { |
@@ -48,4 +50,45 @@ class CouponData | @@ -48,4 +50,45 @@ class CouponData | ||
48 | $param['client_secret'] = Sign::getSign($param); | 50 | $param['client_secret'] = Sign::getSign($param); |
49 | return Yohobuy::get(Yohobuy::API_URL, $param); | 51 | return Yohobuy::get(Yohobuy::API_URL, $param); |
50 | } | 52 | } |
53 | + | ||
54 | + /** | ||
55 | + * 取得公共的参数 | ||
56 | + * | ||
57 | + * @return array | ||
58 | + */ | ||
59 | + public static function param() | ||
60 | + { | ||
61 | + $clientType = self::clientType(); | ||
62 | + $param = array( | ||
63 | + 'app_version' => '3.8.2', | ||
64 | + 'client_type' => $clientType, | ||
65 | + 'os_version' => 'yohobuy:h5', | ||
66 | + 'private_key' => Yohobuy::$privateKeyList[$clientType], | ||
67 | + 'screen_size' => '720x1280', | ||
68 | + 'v' => '7', | ||
69 | + ); | ||
70 | + return $param; | ||
71 | + } | ||
72 | + | ||
73 | + /** | ||
74 | + * 取得当前的客户端类型 | ||
75 | + */ | ||
76 | + public static function clientType() | ||
77 | + { | ||
78 | + // 苹果设备 | ||
79 | + if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone')) { | ||
80 | + return 'iphone'; | ||
81 | + } | ||
82 | + // 苹果IPAD | ||
83 | + elseif (strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) { | ||
84 | + return 'ipad'; | ||
85 | + } | ||
86 | + elseif (stristr($_SERVER['HTTP_USER_AGENT'], 'android')) { | ||
87 | + return 'android'; | ||
88 | + } | ||
89 | + // 其它 | ||
90 | + else { | ||
91 | + return 'web'; | ||
92 | + } | ||
93 | + } | ||
51 | } | 94 | } |
-
Please register or login to post a comment