@@ -7,41 +7,41 @@ |
||
7 | 7 | */ |
8 | 8 | class TopSecretRegisterRequest |
9 | 9 | { |
10 | - /** |
|
11 | - * 用户id,保证唯一 |
|
12 | - **/ |
|
13 | - private $userId; |
|
10 | + /** |
|
11 | + * 用户id,保证唯一 |
|
12 | + **/ |
|
13 | + private $userId; |
|
14 | 14 | |
15 | - private $apiParas = array(); |
|
15 | + private $apiParas = array(); |
|
16 | 16 | |
17 | - public function setUserId($userId) |
|
18 | - { |
|
19 | - $this->userId = $userId; |
|
20 | - $this->apiParas["user_id"] = $userId; |
|
21 | - } |
|
17 | + public function setUserId($userId) |
|
18 | + { |
|
19 | + $this->userId = $userId; |
|
20 | + $this->apiParas["user_id"] = $userId; |
|
21 | + } |
|
22 | 22 | |
23 | - public function getUserId() |
|
24 | - { |
|
25 | - return $this->userId; |
|
26 | - } |
|
23 | + public function getUserId() |
|
24 | + { |
|
25 | + return $this->userId; |
|
26 | + } |
|
27 | 27 | |
28 | - public function getApiMethodName() |
|
29 | - { |
|
30 | - return "taobao.top.secret.register"; |
|
31 | - } |
|
28 | + public function getApiMethodName() |
|
29 | + { |
|
30 | + return "taobao.top.secret.register"; |
|
31 | + } |
|
32 | 32 | |
33 | - public function getApiParas() |
|
34 | - { |
|
35 | - return $this->apiParas; |
|
36 | - } |
|
33 | + public function getApiParas() |
|
34 | + { |
|
35 | + return $this->apiParas; |
|
36 | + } |
|
37 | 37 | |
38 | - public function check() |
|
39 | - { |
|
38 | + public function check() |
|
39 | + { |
|
40 | 40 | |
41 | - } |
|
41 | + } |
|
42 | 42 | |
43 | - public function putOtherTextParam($key, $value) { |
|
44 | - $this->apiParas[$key] = $value; |
|
45 | - $this->$key = $value; |
|
46 | - } |
|
43 | + public function putOtherTextParam($key, $value) { |
|
44 | + $this->apiParas[$key] = $value; |
|
45 | + $this->$key = $value; |
|
46 | + } |
|
47 | 47 | } |
@@ -7,42 +7,42 @@ |
||
7 | 7 | */ |
8 | 8 | class TopAuthTokenRefreshRequest |
9 | 9 | { |
10 | - /** |
|
11 | - * grantType==refresh_token 时需要 |
|
12 | - **/ |
|
13 | - private $refreshToken; |
|
10 | + /** |
|
11 | + * grantType==refresh_token 时需要 |
|
12 | + **/ |
|
13 | + private $refreshToken; |
|
14 | 14 | |
15 | - private $apiParas = array(); |
|
15 | + private $apiParas = array(); |
|
16 | 16 | |
17 | - public function setRefreshToken($refreshToken) |
|
18 | - { |
|
19 | - $this->refreshToken = $refreshToken; |
|
20 | - $this->apiParas["refresh_token"] = $refreshToken; |
|
21 | - } |
|
17 | + public function setRefreshToken($refreshToken) |
|
18 | + { |
|
19 | + $this->refreshToken = $refreshToken; |
|
20 | + $this->apiParas["refresh_token"] = $refreshToken; |
|
21 | + } |
|
22 | 22 | |
23 | - public function getRefreshToken() |
|
24 | - { |
|
25 | - return $this->refreshToken; |
|
26 | - } |
|
23 | + public function getRefreshToken() |
|
24 | + { |
|
25 | + return $this->refreshToken; |
|
26 | + } |
|
27 | 27 | |
28 | - public function getApiMethodName() |
|
29 | - { |
|
30 | - return "taobao.top.auth.token.refresh"; |
|
31 | - } |
|
28 | + public function getApiMethodName() |
|
29 | + { |
|
30 | + return "taobao.top.auth.token.refresh"; |
|
31 | + } |
|
32 | 32 | |
33 | - public function getApiParas() |
|
34 | - { |
|
35 | - return $this->apiParas; |
|
36 | - } |
|
33 | + public function getApiParas() |
|
34 | + { |
|
35 | + return $this->apiParas; |
|
36 | + } |
|
37 | 37 | |
38 | - public function check() |
|
39 | - { |
|
38 | + public function check() |
|
39 | + { |
|
40 | 40 | |
41 | - RequestCheckUtil::checkNotNull($this->refreshToken,"refreshToken"); |
|
42 | - } |
|
41 | + RequestCheckUtil::checkNotNull($this->refreshToken,"refreshToken"); |
|
42 | + } |
|
43 | 43 | |
44 | - public function putOtherTextParam($key, $value) { |
|
45 | - $this->apiParas[$key] = $value; |
|
46 | - $this->$key = $value; |
|
47 | - } |
|
44 | + public function putOtherTextParam($key, $value) { |
|
45 | + $this->apiParas[$key] = $value; |
|
46 | + $this->$key = $value; |
|
47 | + } |
|
48 | 48 | } |
@@ -8,25 +8,25 @@ |
||
8 | 8 | class OpenuidGetRequest |
9 | 9 | { |
10 | 10 | |
11 | - private $apiParas = array(); |
|
11 | + private $apiParas = array(); |
|
12 | 12 | |
13 | - public function getApiMethodName() |
|
14 | - { |
|
15 | - return "taobao.openuid.get"; |
|
16 | - } |
|
13 | + public function getApiMethodName() |
|
14 | + { |
|
15 | + return "taobao.openuid.get"; |
|
16 | + } |
|
17 | 17 | |
18 | - public function getApiParas() |
|
19 | - { |
|
20 | - return $this->apiParas; |
|
21 | - } |
|
18 | + public function getApiParas() |
|
19 | + { |
|
20 | + return $this->apiParas; |
|
21 | + } |
|
22 | 22 | |
23 | - public function check() |
|
24 | - { |
|
23 | + public function check() |
|
24 | + { |
|
25 | 25 | |
26 | - } |
|
26 | + } |
|
27 | 27 | |
28 | - public function putOtherTextParam($key, $value) { |
|
29 | - $this->apiParas[$key] = $value; |
|
30 | - $this->$key = $value; |
|
31 | - } |
|
28 | + public function putOtherTextParam($key, $value) { |
|
29 | + $this->apiParas[$key] = $value; |
|
30 | + $this->$key = $value; |
|
31 | + } |
|
32 | 32 | } |
@@ -1,199 +1,199 @@ |
||
1 | 1 | <?php |
2 | 2 | class ClusterTopClient extends TopClient { |
3 | 3 | |
4 | - private static $dnsconfig; |
|
5 | - private static $syncDate = 0; |
|
6 | - private static $applicationVar ; |
|
7 | - private static $cfgDuration = 10; |
|
8 | - |
|
9 | - public function __construct($appkey = "",$secretKey = ""){ |
|
10 | - ClusterTopClient::$applicationVar = new ApplicationVar; |
|
11 | - $this->appkey = $appkey; |
|
12 | - $this->secretKey = $secretKey ; |
|
13 | - $saveConfig = ClusterTopClient::$applicationVar->getValue(); |
|
14 | - |
|
15 | - if($saveConfig){ |
|
16 | - $tmpConfig = $saveConfig['dnsconfig']; |
|
17 | - ClusterTopClient::$dnsconfig = $this->object_to_array($tmpConfig); |
|
18 | - unset($tmpConfig); |
|
19 | - |
|
20 | - ClusterTopClient::$syncDate = $saveConfig['syncDate']; |
|
21 | - if(!ClusterTopClient::$syncDate) |
|
22 | - ClusterTopClient::$syncDate = 0; |
|
23 | - } |
|
24 | - } |
|
25 | - |
|
26 | - public function __destruct(){ |
|
27 | - if(ClusterTopClient::$dnsconfig && ClusterTopClient::$syncDate){ |
|
28 | - ClusterTopClient::$applicationVar->setValue("dnsconfig",ClusterTopClient::$dnsconfig); |
|
29 | - ClusterTopClient::$applicationVar->setValue("syncDate",ClusterTopClient::$syncDate); |
|
30 | - ClusterTopClient::$applicationVar->write(); |
|
31 | - } |
|
32 | - } |
|
33 | - |
|
34 | - public function execute($request = null, $session = null,$bestUrl = null){ |
|
35 | - $currentDate = date('U'); |
|
36 | - $syncDuration = $this->getDnsConfigSyncDuration(); |
|
37 | - $bestUrl = $this->getBestVipUrl($this->gatewayUrl,$request->getApiMethodName(),$session); |
|
38 | - if($currentDate - ClusterTopClient::$syncDate > $syncDuration * 60){ |
|
39 | - $httpdns = new HttpdnsGetRequest; |
|
40 | - ClusterTopClient::$dnsconfig = json_decode(parent::execute($httpdns,null,$bestUrl)->result,true); |
|
41 | - $syncDate = date('U'); |
|
42 | - ClusterTopClient::$syncDate = $syncDate ; |
|
43 | - } |
|
44 | - return parent::execute($request,$session,$bestUrl); |
|
45 | - } |
|
46 | - |
|
47 | - private function getDnsConfigSyncDuration(){ |
|
48 | - if(ClusterTopClient::$cfgDuration){ |
|
49 | - return ClusterTopClient::$cfgDuration; |
|
50 | - } |
|
51 | - if(!ClusterTopClient::$dnsconfig){ |
|
52 | - return ClusterTopClient::$cfgDuration; |
|
53 | - } |
|
54 | - $config = json_encode(ClusterTopClient::$dnsconfig); |
|
55 | - if(!$config){ |
|
56 | - return ClusterTopClient::$cfgDuration; |
|
57 | - } |
|
58 | - $config = ClusterTopClient::$dnsconfig['config']; |
|
59 | - $duration = $config['interval']; |
|
60 | - ClusterTopClient::$cfgDuration = $duration; |
|
61 | - |
|
62 | - return ClusterTopClient::$cfgDuration; |
|
63 | - } |
|
64 | - |
|
65 | - private function getBestVipUrl($url,$apiname = null,$session = null){ |
|
66 | - $config = ClusterTopClient::$dnsconfig['config']; |
|
67 | - $degrade = $config['degrade']; |
|
68 | - if(strcmp($degrade,'true') == 0){ |
|
69 | - return $url; |
|
70 | - } |
|
71 | - $currentEnv = $this->getEnvByApiName($apiname,$session); |
|
72 | - $vip = $this->getVipByEnv($url,$currentEnv); |
|
73 | - if($vip) |
|
74 | - return $vip; |
|
75 | - return $url; |
|
76 | - } |
|
77 | - |
|
78 | - private function getVipByEnv($comUrl,$currentEnv){ |
|
79 | - $urlSchema = parse_url($comUrl); |
|
80 | - if(!$urlSchema) |
|
81 | - return null; |
|
82 | - if(!ClusterTopClient::$dnsconfig['env']) |
|
83 | - return null; |
|
4 | + private static $dnsconfig; |
|
5 | + private static $syncDate = 0; |
|
6 | + private static $applicationVar ; |
|
7 | + private static $cfgDuration = 10; |
|
8 | + |
|
9 | + public function __construct($appkey = "",$secretKey = ""){ |
|
10 | + ClusterTopClient::$applicationVar = new ApplicationVar; |
|
11 | + $this->appkey = $appkey; |
|
12 | + $this->secretKey = $secretKey ; |
|
13 | + $saveConfig = ClusterTopClient::$applicationVar->getValue(); |
|
14 | + |
|
15 | + if($saveConfig){ |
|
16 | + $tmpConfig = $saveConfig['dnsconfig']; |
|
17 | + ClusterTopClient::$dnsconfig = $this->object_to_array($tmpConfig); |
|
18 | + unset($tmpConfig); |
|
19 | + |
|
20 | + ClusterTopClient::$syncDate = $saveConfig['syncDate']; |
|
21 | + if(!ClusterTopClient::$syncDate) |
|
22 | + ClusterTopClient::$syncDate = 0; |
|
23 | + } |
|
24 | + } |
|
25 | + |
|
26 | + public function __destruct(){ |
|
27 | + if(ClusterTopClient::$dnsconfig && ClusterTopClient::$syncDate){ |
|
28 | + ClusterTopClient::$applicationVar->setValue("dnsconfig",ClusterTopClient::$dnsconfig); |
|
29 | + ClusterTopClient::$applicationVar->setValue("syncDate",ClusterTopClient::$syncDate); |
|
30 | + ClusterTopClient::$applicationVar->write(); |
|
31 | + } |
|
32 | + } |
|
33 | + |
|
34 | + public function execute($request = null, $session = null,$bestUrl = null){ |
|
35 | + $currentDate = date('U'); |
|
36 | + $syncDuration = $this->getDnsConfigSyncDuration(); |
|
37 | + $bestUrl = $this->getBestVipUrl($this->gatewayUrl,$request->getApiMethodName(),$session); |
|
38 | + if($currentDate - ClusterTopClient::$syncDate > $syncDuration * 60){ |
|
39 | + $httpdns = new HttpdnsGetRequest; |
|
40 | + ClusterTopClient::$dnsconfig = json_decode(parent::execute($httpdns,null,$bestUrl)->result,true); |
|
41 | + $syncDate = date('U'); |
|
42 | + ClusterTopClient::$syncDate = $syncDate ; |
|
43 | + } |
|
44 | + return parent::execute($request,$session,$bestUrl); |
|
45 | + } |
|
46 | + |
|
47 | + private function getDnsConfigSyncDuration(){ |
|
48 | + if(ClusterTopClient::$cfgDuration){ |
|
49 | + return ClusterTopClient::$cfgDuration; |
|
50 | + } |
|
51 | + if(!ClusterTopClient::$dnsconfig){ |
|
52 | + return ClusterTopClient::$cfgDuration; |
|
53 | + } |
|
54 | + $config = json_encode(ClusterTopClient::$dnsconfig); |
|
55 | + if(!$config){ |
|
56 | + return ClusterTopClient::$cfgDuration; |
|
57 | + } |
|
58 | + $config = ClusterTopClient::$dnsconfig['config']; |
|
59 | + $duration = $config['interval']; |
|
60 | + ClusterTopClient::$cfgDuration = $duration; |
|
61 | + |
|
62 | + return ClusterTopClient::$cfgDuration; |
|
63 | + } |
|
64 | + |
|
65 | + private function getBestVipUrl($url,$apiname = null,$session = null){ |
|
66 | + $config = ClusterTopClient::$dnsconfig['config']; |
|
67 | + $degrade = $config['degrade']; |
|
68 | + if(strcmp($degrade,'true') == 0){ |
|
69 | + return $url; |
|
70 | + } |
|
71 | + $currentEnv = $this->getEnvByApiName($apiname,$session); |
|
72 | + $vip = $this->getVipByEnv($url,$currentEnv); |
|
73 | + if($vip) |
|
74 | + return $vip; |
|
75 | + return $url; |
|
76 | + } |
|
77 | + |
|
78 | + private function getVipByEnv($comUrl,$currentEnv){ |
|
79 | + $urlSchema = parse_url($comUrl); |
|
80 | + if(!$urlSchema) |
|
81 | + return null; |
|
82 | + if(!ClusterTopClient::$dnsconfig['env']) |
|
83 | + return null; |
|
84 | 84 | |
85 | - if(!array_key_exists($currentEnv,ClusterTopClient::$dnsconfig['env'])) |
|
86 | - return null; |
|
87 | - |
|
88 | - $hostList = ClusterTopClient::$dnsconfig['env'][$currentEnv]; |
|
89 | - if(!$hostList) |
|
90 | - return null ; |
|
91 | - |
|
92 | - $vipList = null; |
|
93 | - foreach ($hostList as $key => $value) { |
|
94 | - if(strcmp($key,$urlSchema['host']) == 0 && strcmp($value['proto'],$urlSchema['scheme']) == 0){ |
|
95 | - $vipList = $value; |
|
96 | - break; |
|
97 | - } |
|
98 | - } |
|
99 | - $vip = $this->getRandomWeightElement($vipList['vip']); |
|
85 | + if(!array_key_exists($currentEnv,ClusterTopClient::$dnsconfig['env'])) |
|
86 | + return null; |
|
87 | + |
|
88 | + $hostList = ClusterTopClient::$dnsconfig['env'][$currentEnv]; |
|
89 | + if(!$hostList) |
|
90 | + return null ; |
|
91 | + |
|
92 | + $vipList = null; |
|
93 | + foreach ($hostList as $key => $value) { |
|
94 | + if(strcmp($key,$urlSchema['host']) == 0 && strcmp($value['proto'],$urlSchema['scheme']) == 0){ |
|
95 | + $vipList = $value; |
|
96 | + break; |
|
97 | + } |
|
98 | + } |
|
99 | + $vip = $this->getRandomWeightElement($vipList['vip']); |
|
100 | 100 | |
101 | - if($vip){ |
|
102 | - return $urlSchema['scheme']."://".$vip.$urlSchema['path']; |
|
103 | - } |
|
104 | - return null; |
|
105 | - } |
|
106 | - |
|
107 | - private function getEnvByApiName($apiName,$session=""){ |
|
108 | - $apiCfgArray = ClusterTopClient::$dnsconfig['api']; |
|
109 | - if($apiCfgArray){ |
|
110 | - if(array_key_exists($apiName,$apiCfgArray)){ |
|
111 | - $apiCfg = $apiCfgArray[$apiName]; |
|
112 | - if(array_key_exists('user',$apiCfg)){ |
|
113 | - $userFlag = $apiCfg['user']; |
|
114 | - $flag = $this->getUserFlag($session); |
|
115 | - if($userFlag && $flag ){ |
|
116 | - return $this->getEnvBySessionFlag($userFlag,$flag); |
|
117 | - }else{ |
|
118 | - return $this->getRandomWeightElement($apiCfg['rule']); |
|
119 | - } |
|
120 | - } |
|
121 | - } |
|
122 | - } |
|
123 | - return $this->getDeafultEnv(); |
|
124 | - } |
|
125 | - |
|
126 | - private function getUserFlag($session){ |
|
127 | - if($session && strlen($session) > 5){ |
|
128 | - if($session[0] == '6' || $session[0] == '7'){ |
|
129 | - return $session[strlen($session) -1]; |
|
130 | - }else if($session[0] == '5' || $session[0] == '8'){ |
|
131 | - return $session[5]; |
|
132 | - } |
|
133 | - } |
|
134 | - return null; |
|
135 | - } |
|
136 | - |
|
137 | - private function getEnvBySessionFlag($targetConfig,$flag){ |
|
138 | - if($flag){ |
|
139 | - $userConf = ClusterTopClient::$dnsconfig['user']; |
|
140 | - $cfgArry = $userConf[$targetConfig]; |
|
141 | - foreach ($cfgArry as $key => $value) { |
|
142 | - if(in_array($flag,$value)) |
|
143 | - return $key; |
|
144 | - } |
|
145 | - }else{ |
|
146 | - return null; |
|
147 | - } |
|
148 | - } |
|
149 | - |
|
150 | - private function getRandomWeightElement($elements){ |
|
151 | - $totalWeight = 0; |
|
152 | - if($elements){ |
|
153 | - foreach ($elements as $ele) { |
|
154 | - $weight = $this->getElementWeight($ele); |
|
155 | - $r = $this->randomFloat() * ($weight + $totalWeight); |
|
156 | - if($r >= $totalWeight){ |
|
157 | - $selected = $ele; |
|
158 | - } |
|
159 | - $totalWeight += $weight; |
|
160 | - } |
|
161 | - if($selected){ |
|
162 | - return $this->getElementValue($selected); |
|
163 | - } |
|
164 | - } |
|
165 | - return null; |
|
166 | - |
|
167 | - } |
|
168 | - |
|
169 | - private function getElementWeight($ele){ |
|
170 | - $params = explode('|', $ele); |
|
171 | - return floatval($params[1]); |
|
172 | - } |
|
173 | - private function getElementValue($ele){ |
|
174 | - $params = explode('|', $ele); |
|
175 | - return $params[0]; |
|
176 | - } |
|
177 | - |
|
178 | - private function getDeafultEnv(){ |
|
179 | - return ClusterTopClient::$dnsconfig['config']['def_env']; |
|
180 | - } |
|
181 | - |
|
182 | - private static function startsWith($haystack, $needle) { |
|
183 | - return $needle === "" || strpos($haystack, $needle) === 0; |
|
184 | - } |
|
185 | - |
|
186 | - private function object_to_array($obj) |
|
187 | - { |
|
188 | - $_arr= is_object($obj) ? get_object_vars($obj) : $obj; |
|
189 | - foreach($_arr as $key=> $val) |
|
190 | - { |
|
191 | - $val= (is_array($val) || is_object($val))? $this->object_to_array($val) : $val; |
|
192 | - $arr[$key] = $val; |
|
193 | - } |
|
194 | - return$arr; |
|
195 | - } |
|
196 | - |
|
197 | - private function randomFloat($min = 0, $max = 1) { return $min + mt_rand() / mt_getrandmax() * ($max - $min); } |
|
101 | + if($vip){ |
|
102 | + return $urlSchema['scheme']."://".$vip.$urlSchema['path']; |
|
103 | + } |
|
104 | + return null; |
|
105 | + } |
|
106 | + |
|
107 | + private function getEnvByApiName($apiName,$session=""){ |
|
108 | + $apiCfgArray = ClusterTopClient::$dnsconfig['api']; |
|
109 | + if($apiCfgArray){ |
|
110 | + if(array_key_exists($apiName,$apiCfgArray)){ |
|
111 | + $apiCfg = $apiCfgArray[$apiName]; |
|
112 | + if(array_key_exists('user',$apiCfg)){ |
|
113 | + $userFlag = $apiCfg['user']; |
|
114 | + $flag = $this->getUserFlag($session); |
|
115 | + if($userFlag && $flag ){ |
|
116 | + return $this->getEnvBySessionFlag($userFlag,$flag); |
|
117 | + }else{ |
|
118 | + return $this->getRandomWeightElement($apiCfg['rule']); |
|
119 | + } |
|
120 | + } |
|
121 | + } |
|
122 | + } |
|
123 | + return $this->getDeafultEnv(); |
|
124 | + } |
|
125 | + |
|
126 | + private function getUserFlag($session){ |
|
127 | + if($session && strlen($session) > 5){ |
|
128 | + if($session[0] == '6' || $session[0] == '7'){ |
|
129 | + return $session[strlen($session) -1]; |
|
130 | + }else if($session[0] == '5' || $session[0] == '8'){ |
|
131 | + return $session[5]; |
|
132 | + } |
|
133 | + } |
|
134 | + return null; |
|
135 | + } |
|
136 | + |
|
137 | + private function getEnvBySessionFlag($targetConfig,$flag){ |
|
138 | + if($flag){ |
|
139 | + $userConf = ClusterTopClient::$dnsconfig['user']; |
|
140 | + $cfgArry = $userConf[$targetConfig]; |
|
141 | + foreach ($cfgArry as $key => $value) { |
|
142 | + if(in_array($flag,$value)) |
|
143 | + return $key; |
|
144 | + } |
|
145 | + }else{ |
|
146 | + return null; |
|
147 | + } |
|
148 | + } |
|
149 | + |
|
150 | + private function getRandomWeightElement($elements){ |
|
151 | + $totalWeight = 0; |
|
152 | + if($elements){ |
|
153 | + foreach ($elements as $ele) { |
|
154 | + $weight = $this->getElementWeight($ele); |
|
155 | + $r = $this->randomFloat() * ($weight + $totalWeight); |
|
156 | + if($r >= $totalWeight){ |
|
157 | + $selected = $ele; |
|
158 | + } |
|
159 | + $totalWeight += $weight; |
|
160 | + } |
|
161 | + if($selected){ |
|
162 | + return $this->getElementValue($selected); |
|
163 | + } |
|
164 | + } |
|
165 | + return null; |
|
166 | + |
|
167 | + } |
|
168 | + |
|
169 | + private function getElementWeight($ele){ |
|
170 | + $params = explode('|', $ele); |
|
171 | + return floatval($params[1]); |
|
172 | + } |
|
173 | + private function getElementValue($ele){ |
|
174 | + $params = explode('|', $ele); |
|
175 | + return $params[0]; |
|
176 | + } |
|
177 | + |
|
178 | + private function getDeafultEnv(){ |
|
179 | + return ClusterTopClient::$dnsconfig['config']['def_env']; |
|
180 | + } |
|
181 | + |
|
182 | + private static function startsWith($haystack, $needle) { |
|
183 | + return $needle === "" || strpos($haystack, $needle) === 0; |
|
184 | + } |
|
185 | + |
|
186 | + private function object_to_array($obj) |
|
187 | + { |
|
188 | + $_arr= is_object($obj) ? get_object_vars($obj) : $obj; |
|
189 | + foreach($_arr as $key=> $val) |
|
190 | + { |
|
191 | + $val= (is_array($val) || is_object($val))? $this->object_to_array($val) : $val; |
|
192 | + $arr[$key] = $val; |
|
193 | + } |
|
194 | + return$arr; |
|
195 | + } |
|
196 | + |
|
197 | + private function randomFloat($min = 0, $max = 1) { return $min + mt_rand() / mt_getrandmax() * ($max - $min); } |
|
198 | 198 | } |
199 | 199 | ?> |
200 | 200 | \ No newline at end of file |
@@ -1,255 +1,255 @@ |
||
1 | 1 | <?php |
2 | 2 | class AliyunClient |
3 | 3 | { |
4 | - public $accessKeyId; |
|
4 | + public $accessKeyId; |
|
5 | 5 | |
6 | - public $accessKeySecret; |
|
6 | + public $accessKeySecret; |
|
7 | 7 | |
8 | - public $serverUrl = "http://ecs.aliyuncs.com/"; |
|
8 | + public $serverUrl = "http://ecs.aliyuncs.com/"; |
|
9 | 9 | |
10 | - public $format = "json"; |
|
10 | + public $format = "json"; |
|
11 | 11 | |
12 | - public $connectTimeout = 3000;//3秒 |
|
12 | + public $connectTimeout = 3000;//3秒 |
|
13 | 13 | |
14 | - public $readTimeout = 80000;//80秒 |
|
14 | + public $readTimeout = 80000;//80秒 |
|
15 | 15 | |
16 | - /** 是否打开入参check**/ |
|
17 | - public $checkRequest = true; |
|
16 | + /** 是否打开入参check**/ |
|
17 | + public $checkRequest = true; |
|
18 | 18 | |
19 | - protected $signatureMethod = "HMAC-SHA1"; |
|
19 | + protected $signatureMethod = "HMAC-SHA1"; |
|
20 | 20 | |
21 | - protected $signatureVersion = "1.0"; |
|
21 | + protected $signatureVersion = "1.0"; |
|
22 | 22 | |
23 | 23 | protected $dateTimeFormat = 'Y-m-d\TH:i:s\Z'; // ISO8601规范 |
24 | 24 | |
25 | - protected $sdkVersion = "1.0"; |
|
26 | - |
|
27 | - public function execute($request) |
|
28 | - { |
|
29 | - if($this->checkRequest) { |
|
30 | - try { |
|
31 | - $request->check(); |
|
32 | - } catch (Exception $e) { |
|
33 | - $result->code = $e->getCode(); |
|
34 | - $result->message = $e->getMessage(); |
|
35 | - return $result; |
|
36 | - } |
|
37 | - } |
|
38 | - //获取业务参数 |
|
39 | - $apiParams = $request->getApiParas(); |
|
40 | - //组装系统参数 |
|
41 | - $apiParams["AccessKeyId"] = $this->accessKeyId; |
|
42 | - $apiParams["Format"] = $this->format;// |
|
43 | - $apiParams["SignatureMethod"] = $this->signatureMethod; |
|
44 | - $apiParams["SignatureVersion"] = $this->signatureVersion; |
|
45 | - $apiParams["SignatureNonce"] = uniqid(); |
|
46 | - date_default_timezone_set("GMT"); |
|
47 | - $apiParams["TimeStamp"] = date($this->dateTimeFormat); |
|
48 | - $apiParams["partner_id"] = $this->sdkVersion; |
|
25 | + protected $sdkVersion = "1.0"; |
|
26 | + |
|
27 | + public function execute($request) |
|
28 | + { |
|
29 | + if($this->checkRequest) { |
|
30 | + try { |
|
31 | + $request->check(); |
|
32 | + } catch (Exception $e) { |
|
33 | + $result->code = $e->getCode(); |
|
34 | + $result->message = $e->getMessage(); |
|
35 | + return $result; |
|
36 | + } |
|
37 | + } |
|
38 | + //获取业务参数 |
|
39 | + $apiParams = $request->getApiParas(); |
|
40 | + //组装系统参数 |
|
41 | + $apiParams["AccessKeyId"] = $this->accessKeyId; |
|
42 | + $apiParams["Format"] = $this->format;// |
|
43 | + $apiParams["SignatureMethod"] = $this->signatureMethod; |
|
44 | + $apiParams["SignatureVersion"] = $this->signatureVersion; |
|
45 | + $apiParams["SignatureNonce"] = uniqid(); |
|
46 | + date_default_timezone_set("GMT"); |
|
47 | + $apiParams["TimeStamp"] = date($this->dateTimeFormat); |
|
48 | + $apiParams["partner_id"] = $this->sdkVersion; |
|
49 | 49 | |
50 | - $apiNameArray = split("\.", $request->getApiMethodName()); |
|
51 | - $apiParams["Action"] = $apiNameArray[3]; |
|
52 | - $apiParams["Version"] = $apiNameArray[4]; |
|
53 | - //签名 |
|
54 | - $apiParams["Signature"] = $this->computeSignature($apiParams, $this->accessKeySecret); |
|
55 | - |
|
56 | - //系统参数放入GET请求串 |
|
57 | - $requestUrl = rtrim($this->serverUrl,"/") . "/?"; |
|
58 | - foreach ($apiParams as $apiParamKey => $apiParamValue) |
|
59 | - { |
|
60 | - $requestUrl .= "$apiParamKey=" . urlencode($apiParamValue) . "&"; |
|
61 | - } |
|
62 | - $requestUrl = substr($requestUrl, 0, -1); |
|
63 | - //发起HTTP请求 |
|
64 | - try |
|
65 | - { |
|
66 | - $resp = $this->curl($requestUrl, null); |
|
67 | - } |
|
68 | - catch (Exception $e) |
|
69 | - { |
|
70 | - $this->logCommunicationError($apiParams["Action"],$requestUrl,"HTTP_ERROR_" . $e->getCode(),$e->getMessage()); |
|
71 | - if ("json" == $this->format) |
|
72 | - { |
|
73 | - return json_decode($e->getMessage()); |
|
74 | - } |
|
75 | - else if("xml" == $this->format) |
|
76 | - { |
|
77 | - return @simplexml_load_string($e->getMessage()); |
|
78 | - } |
|
79 | - } |
|
80 | - |
|
81 | - //解析API返回结果 |
|
82 | - $respWellFormed = false; |
|
83 | - if ("json" == $this->format) |
|
84 | - { |
|
85 | - $respObject = json_decode($resp); |
|
86 | - if (null !== $respObject) |
|
87 | - { |
|
88 | - $respWellFormed = true; |
|
89 | - } |
|
90 | - } |
|
91 | - else if("xml" == $this->format) |
|
92 | - { |
|
93 | - $respObject = @simplexml_load_string($resp); |
|
94 | - if (false !== $respObject) |
|
95 | - { |
|
96 | - $respWellFormed = true; |
|
97 | - } |
|
98 | - } |
|
99 | - |
|
100 | - //返回的HTTP文本不是标准JSON或者XML,记下错误日志 |
|
101 | - if (false === $respWellFormed) |
|
102 | - { |
|
103 | - $this->logCommunicationError($apiParams["Action"],$requestUrl,"HTTP_RESPONSE_NOT_WELL_FORMED",$resp); |
|
104 | - $result->code = 0; |
|
105 | - $result->message = "HTTP_RESPONSE_NOT_WELL_FORMED"; |
|
106 | - return $result; |
|
107 | - } |
|
108 | - |
|
109 | - //如果TOP返回了错误码,记录到业务错误日志中 |
|
110 | - if (isset($respObject->code)) |
|
111 | - { |
|
112 | - $logger = new LtLogger; |
|
113 | - $logger->conf["log_file"] = rtrim(TOP_SDK_WORK_DIR, '\\/') . '/' . "logs/top_biz_err_" . $this->appkey . "_" . date("Y-m-d") . ".log"; |
|
114 | - $logger->log(array( |
|
115 | - date("Y-m-d H:i:s"), |
|
116 | - $resp |
|
117 | - )); |
|
118 | - } |
|
119 | - return $respObject; |
|
120 | - } |
|
121 | - |
|
122 | - public function exec($paramsArray) |
|
123 | - { |
|
124 | - if (!isset($paramsArray["Action"])) |
|
125 | - { |
|
126 | - trigger_error("No api name passed"); |
|
127 | - } |
|
128 | - $inflector = new LtInflector; |
|
129 | - $inflector->conf["separator"] = "."; |
|
130 | - $requestClassName = ucfirst($inflector->camelize(substr($paramsArray["Action"], 7))) . "Request"; |
|
131 | - if (!class_exists($requestClassName)) |
|
132 | - { |
|
133 | - trigger_error("No such api: " . $paramsArray["Action"]); |
|
134 | - } |
|
135 | - |
|
136 | - $req = new $requestClassName; |
|
137 | - foreach($paramsArray as $paraKey => $paraValue) |
|
138 | - { |
|
139 | - $inflector->conf["separator"] = "_"; |
|
140 | - $setterMethodName = $inflector->camelize($paraKey); |
|
141 | - $inflector->conf["separator"] = "."; |
|
142 | - $setterMethodName = "set" . $inflector->camelize($setterMethodName); |
|
143 | - if (method_exists($req, $setterMethodName)) |
|
144 | - { |
|
145 | - $req->$setterMethodName($paraValue); |
|
146 | - } |
|
147 | - } |
|
148 | - return $this->execute($req, $session); |
|
149 | - } |
|
50 | + $apiNameArray = split("\.", $request->getApiMethodName()); |
|
51 | + $apiParams["Action"] = $apiNameArray[3]; |
|
52 | + $apiParams["Version"] = $apiNameArray[4]; |
|
53 | + //签名 |
|
54 | + $apiParams["Signature"] = $this->computeSignature($apiParams, $this->accessKeySecret); |
|
55 | + |
|
56 | + //系统参数放入GET请求串 |
|
57 | + $requestUrl = rtrim($this->serverUrl,"/") . "/?"; |
|
58 | + foreach ($apiParams as $apiParamKey => $apiParamValue) |
|
59 | + { |
|
60 | + $requestUrl .= "$apiParamKey=" . urlencode($apiParamValue) . "&"; |
|
61 | + } |
|
62 | + $requestUrl = substr($requestUrl, 0, -1); |
|
63 | + //发起HTTP请求 |
|
64 | + try |
|
65 | + { |
|
66 | + $resp = $this->curl($requestUrl, null); |
|
67 | + } |
|
68 | + catch (Exception $e) |
|
69 | + { |
|
70 | + $this->logCommunicationError($apiParams["Action"],$requestUrl,"HTTP_ERROR_" . $e->getCode(),$e->getMessage()); |
|
71 | + if ("json" == $this->format) |
|
72 | + { |
|
73 | + return json_decode($e->getMessage()); |
|
74 | + } |
|
75 | + else if("xml" == $this->format) |
|
76 | + { |
|
77 | + return @simplexml_load_string($e->getMessage()); |
|
78 | + } |
|
79 | + } |
|
80 | + |
|
81 | + //解析API返回结果 |
|
82 | + $respWellFormed = false; |
|
83 | + if ("json" == $this->format) |
|
84 | + { |
|
85 | + $respObject = json_decode($resp); |
|
86 | + if (null !== $respObject) |
|
87 | + { |
|
88 | + $respWellFormed = true; |
|
89 | + } |
|
90 | + } |
|
91 | + else if("xml" == $this->format) |
|
92 | + { |
|
93 | + $respObject = @simplexml_load_string($resp); |
|
94 | + if (false !== $respObject) |
|
95 | + { |
|
96 | + $respWellFormed = true; |
|
97 | + } |
|
98 | + } |
|
99 | + |
|
100 | + //返回的HTTP文本不是标准JSON或者XML,记下错误日志 |
|
101 | + if (false === $respWellFormed) |
|
102 | + { |
|
103 | + $this->logCommunicationError($apiParams["Action"],$requestUrl,"HTTP_RESPONSE_NOT_WELL_FORMED",$resp); |
|
104 | + $result->code = 0; |
|
105 | + $result->message = "HTTP_RESPONSE_NOT_WELL_FORMED"; |
|
106 | + return $result; |
|
107 | + } |
|
108 | + |
|
109 | + //如果TOP返回了错误码,记录到业务错误日志中 |
|
110 | + if (isset($respObject->code)) |
|
111 | + { |
|
112 | + $logger = new LtLogger; |
|
113 | + $logger->conf["log_file"] = rtrim(TOP_SDK_WORK_DIR, '\\/') . '/' . "logs/top_biz_err_" . $this->appkey . "_" . date("Y-m-d") . ".log"; |
|
114 | + $logger->log(array( |
|
115 | + date("Y-m-d H:i:s"), |
|
116 | + $resp |
|
117 | + )); |
|
118 | + } |
|
119 | + return $respObject; |
|
120 | + } |
|
121 | + |
|
122 | + public function exec($paramsArray) |
|
123 | + { |
|
124 | + if (!isset($paramsArray["Action"])) |
|
125 | + { |
|
126 | + trigger_error("No api name passed"); |
|
127 | + } |
|
128 | + $inflector = new LtInflector; |
|
129 | + $inflector->conf["separator"] = "."; |
|
130 | + $requestClassName = ucfirst($inflector->camelize(substr($paramsArray["Action"], 7))) . "Request"; |
|
131 | + if (!class_exists($requestClassName)) |
|
132 | + { |
|
133 | + trigger_error("No such api: " . $paramsArray["Action"]); |
|
134 | + } |
|
135 | + |
|
136 | + $req = new $requestClassName; |
|
137 | + foreach($paramsArray as $paraKey => $paraValue) |
|
138 | + { |
|
139 | + $inflector->conf["separator"] = "_"; |
|
140 | + $setterMethodName = $inflector->camelize($paraKey); |
|
141 | + $inflector->conf["separator"] = "."; |
|
142 | + $setterMethodName = "set" . $inflector->camelize($setterMethodName); |
|
143 | + if (method_exists($req, $setterMethodName)) |
|
144 | + { |
|
145 | + $req->$setterMethodName($paraValue); |
|
146 | + } |
|
147 | + } |
|
148 | + return $this->execute($req, $session); |
|
149 | + } |
|
150 | 150 | |
151 | - protected function percentEncode($str) |
|
152 | - { |
|
153 | - // 使用urlencode编码后,将"+","*","%7E"做替换即满足 API规定的编码规范 |
|
154 | - $res = urlencode($str); |
|
155 | - $res = preg_replace('/\+/', '%20', $res); |
|
156 | - $res = preg_replace('/\*/', '%2A', $res); |
|
157 | - $res = preg_replace('/%7E/', '~', $res); |
|
158 | - return $res; |
|
159 | - } |
|
151 | + protected function percentEncode($str) |
|
152 | + { |
|
153 | + // 使用urlencode编码后,将"+","*","%7E"做替换即满足 API规定的编码规范 |
|
154 | + $res = urlencode($str); |
|
155 | + $res = preg_replace('/\+/', '%20', $res); |
|
156 | + $res = preg_replace('/\*/', '%2A', $res); |
|
157 | + $res = preg_replace('/%7E/', '~', $res); |
|
158 | + return $res; |
|
159 | + } |
|
160 | 160 | |
161 | - protected function computeSignature($parameters, $accessKeySecret) |
|
162 | - { |
|
163 | - // 将参数Key按字典顺序排序 |
|
164 | - ksort($parameters); |
|
161 | + protected function computeSignature($parameters, $accessKeySecret) |
|
162 | + { |
|
163 | + // 将参数Key按字典顺序排序 |
|
164 | + ksort($parameters); |
|
165 | 165 | |
166 | - // 生成规范化请求字符串 |
|
167 | - $canonicalizedQueryString = ''; |
|
168 | - foreach($parameters as $key => $value) |
|
169 | - { |
|
170 | - $canonicalizedQueryString .= '&' . $this->percentEncode($key) |
|
171 | - . '=' . $this->percentEncode($value); |
|
172 | - } |
|
166 | + // 生成规范化请求字符串 |
|
167 | + $canonicalizedQueryString = ''; |
|
168 | + foreach($parameters as $key => $value) |
|
169 | + { |
|
170 | + $canonicalizedQueryString .= '&' . $this->percentEncode($key) |
|
171 | + . '=' . $this->percentEncode($value); |
|
172 | + } |
|
173 | 173 | |
174 | - // 生成用于计算签名的字符串 stringToSign |
|
175 | - $stringToSign = 'GET&%2F&' . $this->percentencode(substr($canonicalizedQueryString, 1)); |
|
174 | + // 生成用于计算签名的字符串 stringToSign |
|
175 | + $stringToSign = 'GET&%2F&' . $this->percentencode(substr($canonicalizedQueryString, 1)); |
|
176 | 176 | |
177 | - // 计算签名,注意accessKeySecret后面要加上字符'&' |
|
178 | - $signature = base64_encode(hash_hmac('sha1', $stringToSign, $accessKeySecret . '&', true)); |
|
179 | - return $signature; |
|
180 | - } |
|
177 | + // 计算签名,注意accessKeySecret后面要加上字符'&' |
|
178 | + $signature = base64_encode(hash_hmac('sha1', $stringToSign, $accessKeySecret . '&', true)); |
|
179 | + return $signature; |
|
180 | + } |
|
181 | 181 | |
182 | 182 | public function curl($url, $postFields = null) |
183 | - { |
|
184 | - $ch = curl_init(); |
|
185 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
186 | - curl_setopt($ch, CURLOPT_FAILONERROR, false); |
|
187 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
188 | - if ($this->readTimeout) { |
|
189 | - curl_setopt($ch, CURLOPT_TIMEOUT, $this->readTimeout); |
|
190 | - } |
|
191 | - if ($this->connectTimeout) { |
|
192 | - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->connectTimeout); |
|
193 | - } |
|
194 | - //https 请求 |
|
195 | - if(strlen($url) > 5 && strtolower(substr($url,0,5)) == "https" ) { |
|
196 | - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
|
197 | - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
|
198 | - } |
|
199 | - |
|
200 | - if (is_array($postFields) && 0 < count($postFields)) |
|
201 | - { |
|
202 | - $postBodyString = ""; |
|
203 | - $postMultipart = false; |
|
204 | - foreach ($postFields as $k => $v) |
|
205 | - { |
|
206 | - if("@" != substr($v, 0, 1))//判断是不是文件上传 |
|
207 | - { |
|
208 | - $postBodyString .= "$k=" . urlencode($v) . "&"; |
|
209 | - } |
|
210 | - else//文件上传用multipart/form-data,否则用www-form-urlencoded |
|
211 | - { |
|
212 | - $postMultipart = true; |
|
213 | - } |
|
214 | - } |
|
215 | - unset($k, $v); |
|
216 | - curl_setopt($ch, CURLOPT_POST, true); |
|
217 | - if ($postMultipart) |
|
218 | - { |
|
219 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields); |
|
220 | - } |
|
221 | - else |
|
222 | - { |
|
223 | - curl_setopt($ch, CURLOPT_POSTFIELDS, substr($postBodyString,0,-1)); |
|
224 | - } |
|
225 | - } |
|
226 | - $reponse = curl_exec($ch); |
|
183 | + { |
|
184 | + $ch = curl_init(); |
|
185 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
186 | + curl_setopt($ch, CURLOPT_FAILONERROR, false); |
|
187 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
188 | + if ($this->readTimeout) { |
|
189 | + curl_setopt($ch, CURLOPT_TIMEOUT, $this->readTimeout); |
|
190 | + } |
|
191 | + if ($this->connectTimeout) { |
|
192 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->connectTimeout); |
|
193 | + } |
|
194 | + //https 请求 |
|
195 | + if(strlen($url) > 5 && strtolower(substr($url,0,5)) == "https" ) { |
|
196 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
|
197 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
|
198 | + } |
|
199 | + |
|
200 | + if (is_array($postFields) && 0 < count($postFields)) |
|
201 | + { |
|
202 | + $postBodyString = ""; |
|
203 | + $postMultipart = false; |
|
204 | + foreach ($postFields as $k => $v) |
|
205 | + { |
|
206 | + if("@" != substr($v, 0, 1))//判断是不是文件上传 |
|
207 | + { |
|
208 | + $postBodyString .= "$k=" . urlencode($v) . "&"; |
|
209 | + } |
|
210 | + else//文件上传用multipart/form-data,否则用www-form-urlencoded |
|
211 | + { |
|
212 | + $postMultipart = true; |
|
213 | + } |
|
214 | + } |
|
215 | + unset($k, $v); |
|
216 | + curl_setopt($ch, CURLOPT_POST, true); |
|
217 | + if ($postMultipart) |
|
218 | + { |
|
219 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields); |
|
220 | + } |
|
221 | + else |
|
222 | + { |
|
223 | + curl_setopt($ch, CURLOPT_POSTFIELDS, substr($postBodyString,0,-1)); |
|
224 | + } |
|
225 | + } |
|
226 | + $reponse = curl_exec($ch); |
|
227 | 227 | |
228 | - if (curl_errno($ch)) |
|
229 | - { |
|
230 | - throw new Exception(curl_error($ch),0); |
|
231 | - } |
|
232 | - curl_close($ch); |
|
233 | - return $reponse; |
|
234 | - } |
|
235 | - |
|
236 | - protected function logCommunicationError($apiName, $requestUrl, $errorCode, $responseTxt) |
|
237 | - { |
|
238 | - $localIp = isset($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"] : "CLI"; |
|
239 | - $logger = new LtLogger; |
|
240 | - $logger->conf["log_file"] = rtrim(TOP_SDK_WORK_DIR, '\\/') . '/' . "logs/top_comm_err_" . $this->accessKeyId . "_" . date("Y-m-d") . ".log"; |
|
241 | - $logger->conf["separator"] = "^_^"; |
|
242 | - $logData = array( |
|
243 | - date("Y-m-d H:i:s"), |
|
244 | - $apiName, |
|
245 | - $this->accessKeyId, |
|
246 | - $localIp, |
|
247 | - PHP_OS, |
|
248 | - $this->sdkVersion, |
|
249 | - $requestUrl, |
|
250 | - $errorCode, |
|
251 | - str_replace("\n","",$responseTxt) |
|
252 | - ); |
|
253 | - $logger->log($logData); |
|
254 | - } |
|
228 | + if (curl_errno($ch)) |
|
229 | + { |
|
230 | + throw new Exception(curl_error($ch),0); |
|
231 | + } |
|
232 | + curl_close($ch); |
|
233 | + return $reponse; |
|
234 | + } |
|
235 | + |
|
236 | + protected function logCommunicationError($apiName, $requestUrl, $errorCode, $responseTxt) |
|
237 | + { |
|
238 | + $localIp = isset($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"] : "CLI"; |
|
239 | + $logger = new LtLogger; |
|
240 | + $logger->conf["log_file"] = rtrim(TOP_SDK_WORK_DIR, '\\/') . '/' . "logs/top_comm_err_" . $this->accessKeyId . "_" . date("Y-m-d") . ".log"; |
|
241 | + $logger->conf["separator"] = "^_^"; |
|
242 | + $logData = array( |
|
243 | + date("Y-m-d H:i:s"), |
|
244 | + $apiName, |
|
245 | + $this->accessKeyId, |
|
246 | + $localIp, |
|
247 | + PHP_OS, |
|
248 | + $this->sdkVersion, |
|
249 | + $requestUrl, |
|
250 | + $errorCode, |
|
251 | + str_replace("\n","",$responseTxt) |
|
252 | + ); |
|
253 | + $logger->log($logData); |
|
254 | + } |
|
255 | 255 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | class Autoloader{ |
4 | 4 | |
5 | - /** |
|
5 | + /** |
|
6 | 6 | * 类库自动加载,写死路径,确保不加载其他文件。 |
7 | 7 | * @param string $class 对象类名 |
8 | 8 | * @return void |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | public static function autoload($class) { |
11 | 11 | $name = $class; |
12 | 12 | if(false !== strpos($name,'\\')){ |
13 | - $name = strstr($class, '\\', true); |
|
13 | + $name = strstr($class, '\\', true); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | $filename = TOP_AUTOLOADER_PATH."/top/".$name.".php"; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | return; |
67 | 67 | } |
68 | 68 | |
69 | - $filename = TOP_AUTOLOADER_PATH."/QimenCloud/".$name.".php"; |
|
69 | + $filename = TOP_AUTOLOADER_PATH."/QimenCloud/".$name.".php"; |
|
70 | 70 | if(is_file($filename)) { |
71 | 71 | include $filename; |
72 | 72 | return; |
@@ -7,98 +7,98 @@ |
||
7 | 7 | class PddStockDepotPriorityUpdateRequest extends PopBaseHttpRequest |
8 | 8 | { |
9 | 9 | public function __construct() |
10 | - { |
|
10 | + { |
|
11 | 11 | |
12 | - } |
|
13 | - /** |
|
14 | - * @JsonProperty(List<\Com\Pdd\Pop\Sdk\Api\Request\PddStockDepotPriorityUpdateRequest_PriorityListItem>, "priority_list") |
|
15 | - */ |
|
16 | - private $priorityList; |
|
12 | + } |
|
13 | + /** |
|
14 | + * @JsonProperty(List<\Com\Pdd\Pop\Sdk\Api\Request\PddStockDepotPriorityUpdateRequest_PriorityListItem>, "priority_list") |
|
15 | + */ |
|
16 | + private $priorityList; |
|
17 | 17 | |
18 | - protected function setUserParams(&$params) |
|
19 | - { |
|
20 | - $this->setUserParam($params, "priority_list", $this->priorityList); |
|
18 | + protected function setUserParams(&$params) |
|
19 | + { |
|
20 | + $this->setUserParam($params, "priority_list", $this->priorityList); |
|
21 | 21 | |
22 | - } |
|
22 | + } |
|
23 | 23 | |
24 | - public function getVersion() |
|
25 | - { |
|
26 | - return "V1"; |
|
27 | - } |
|
24 | + public function getVersion() |
|
25 | + { |
|
26 | + return "V1"; |
|
27 | + } |
|
28 | 28 | |
29 | - public function getDataType() |
|
30 | - { |
|
31 | - return "JSON"; |
|
32 | - } |
|
29 | + public function getDataType() |
|
30 | + { |
|
31 | + return "JSON"; |
|
32 | + } |
|
33 | 33 | |
34 | - public function getType() |
|
35 | - { |
|
36 | - return "pdd.stock.depot.priority.update"; |
|
37 | - } |
|
34 | + public function getType() |
|
35 | + { |
|
36 | + return "pdd.stock.depot.priority.update"; |
|
37 | + } |
|
38 | 38 | |
39 | - public function setPriorityList($priorityList) |
|
40 | - { |
|
41 | - $this->priorityList = $priorityList; |
|
42 | - } |
|
39 | + public function setPriorityList($priorityList) |
|
40 | + { |
|
41 | + $this->priorityList = $priorityList; |
|
42 | + } |
|
43 | 43 | |
44 | 44 | } |
45 | 45 | |
46 | 46 | class PddStockDepotPriorityUpdateRequest_PriorityListItem extends PopBaseJsonEntity |
47 | 47 | { |
48 | 48 | |
49 | - public function __construct() |
|
50 | - { |
|
51 | - |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * @JsonProperty(Integer, "priority") |
|
56 | - */ |
|
57 | - private $priority; |
|
58 | - |
|
59 | - /** |
|
60 | - * @JsonProperty(Integer, "district_id") |
|
61 | - */ |
|
62 | - private $districtId; |
|
63 | - |
|
64 | - /** |
|
65 | - * @JsonProperty(Integer, "city_id") |
|
66 | - */ |
|
67 | - private $cityId; |
|
68 | - |
|
69 | - /** |
|
70 | - * @JsonProperty(Integer, "province_id") |
|
71 | - */ |
|
72 | - private $provinceId; |
|
73 | - |
|
74 | - /** |
|
75 | - * @JsonProperty(Long, "depot_id") |
|
76 | - */ |
|
77 | - private $depotId; |
|
78 | - |
|
79 | - public function setPriority($priority) |
|
80 | - { |
|
81 | - $this->priority = $priority; |
|
82 | - } |
|
83 | - |
|
84 | - public function setDistrictId($districtId) |
|
85 | - { |
|
86 | - $this->districtId = $districtId; |
|
87 | - } |
|
88 | - |
|
89 | - public function setCityId($cityId) |
|
90 | - { |
|
91 | - $this->cityId = $cityId; |
|
92 | - } |
|
93 | - |
|
94 | - public function setProvinceId($provinceId) |
|
95 | - { |
|
96 | - $this->provinceId = $provinceId; |
|
97 | - } |
|
98 | - |
|
99 | - public function setDepotId($depotId) |
|
100 | - { |
|
101 | - $this->depotId = $depotId; |
|
102 | - } |
|
49 | + public function __construct() |
|
50 | + { |
|
51 | + |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * @JsonProperty(Integer, "priority") |
|
56 | + */ |
|
57 | + private $priority; |
|
58 | + |
|
59 | + /** |
|
60 | + * @JsonProperty(Integer, "district_id") |
|
61 | + */ |
|
62 | + private $districtId; |
|
63 | + |
|
64 | + /** |
|
65 | + * @JsonProperty(Integer, "city_id") |
|
66 | + */ |
|
67 | + private $cityId; |
|
68 | + |
|
69 | + /** |
|
70 | + * @JsonProperty(Integer, "province_id") |
|
71 | + */ |
|
72 | + private $provinceId; |
|
73 | + |
|
74 | + /** |
|
75 | + * @JsonProperty(Long, "depot_id") |
|
76 | + */ |
|
77 | + private $depotId; |
|
78 | + |
|
79 | + public function setPriority($priority) |
|
80 | + { |
|
81 | + $this->priority = $priority; |
|
82 | + } |
|
83 | + |
|
84 | + public function setDistrictId($districtId) |
|
85 | + { |
|
86 | + $this->districtId = $districtId; |
|
87 | + } |
|
88 | + |
|
89 | + public function setCityId($cityId) |
|
90 | + { |
|
91 | + $this->cityId = $cityId; |
|
92 | + } |
|
93 | + |
|
94 | + public function setProvinceId($provinceId) |
|
95 | + { |
|
96 | + $this->provinceId = $provinceId; |
|
97 | + } |
|
98 | + |
|
99 | + public function setDepotId($depotId) |
|
100 | + { |
|
101 | + $this->depotId = $depotId; |
|
102 | + } |
|
103 | 103 | |
104 | 104 | } |
@@ -7,27 +7,27 @@ |
||
7 | 7 | class PddLogisticsTicketProblemTypeGetRequest extends PopBaseHttpRequest |
8 | 8 | { |
9 | 9 | public function __construct() |
10 | - { |
|
10 | + { |
|
11 | 11 | |
12 | - } |
|
13 | - protected function setUserParams(&$params) |
|
14 | - { |
|
12 | + } |
|
13 | + protected function setUserParams(&$params) |
|
14 | + { |
|
15 | 15 | |
16 | - } |
|
16 | + } |
|
17 | 17 | |
18 | - public function getVersion() |
|
19 | - { |
|
20 | - return "V1"; |
|
21 | - } |
|
18 | + public function getVersion() |
|
19 | + { |
|
20 | + return "V1"; |
|
21 | + } |
|
22 | 22 | |
23 | - public function getDataType() |
|
24 | - { |
|
25 | - return "JSON"; |
|
26 | - } |
|
23 | + public function getDataType() |
|
24 | + { |
|
25 | + return "JSON"; |
|
26 | + } |
|
27 | 27 | |
28 | - public function getType() |
|
29 | - { |
|
30 | - return "pdd.logistics.ticket.problem.type.get"; |
|
31 | - } |
|
28 | + public function getType() |
|
29 | + { |
|
30 | + return "pdd.logistics.ticket.problem.type.get"; |
|
31 | + } |
|
32 | 32 | |
33 | 33 | } |
@@ -7,60 +7,60 @@ |
||
7 | 7 | class PddDdkOauthGoodsPidQueryRequest extends PopBaseHttpRequest |
8 | 8 | { |
9 | 9 | public function __construct() |
10 | - { |
|
10 | + { |
|
11 | 11 | |
12 | - } |
|
13 | - /** |
|
14 | - * @JsonProperty(Integer, "page") |
|
15 | - */ |
|
16 | - private $page; |
|
12 | + } |
|
13 | + /** |
|
14 | + * @JsonProperty(Integer, "page") |
|
15 | + */ |
|
16 | + private $page; |
|
17 | 17 | |
18 | - /** |
|
19 | - * @JsonProperty(Integer, "page_size") |
|
20 | - */ |
|
21 | - private $pageSize; |
|
18 | + /** |
|
19 | + * @JsonProperty(Integer, "page_size") |
|
20 | + */ |
|
21 | + private $pageSize; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @JsonProperty(List<String>, "pid_list") |
|
25 | - */ |
|
26 | - private $pidList; |
|
23 | + /** |
|
24 | + * @JsonProperty(List<String>, "pid_list") |
|
25 | + */ |
|
26 | + private $pidList; |
|
27 | 27 | |
28 | - protected function setUserParams(&$params) |
|
29 | - { |
|
30 | - $this->setUserParam($params, "page", $this->page); |
|
31 | - $this->setUserParam($params, "page_size", $this->pageSize); |
|
32 | - $this->setUserParam($params, "pid_list", $this->pidList); |
|
28 | + protected function setUserParams(&$params) |
|
29 | + { |
|
30 | + $this->setUserParam($params, "page", $this->page); |
|
31 | + $this->setUserParam($params, "page_size", $this->pageSize); |
|
32 | + $this->setUserParam($params, "pid_list", $this->pidList); |
|
33 | 33 | |
34 | - } |
|
34 | + } |
|
35 | 35 | |
36 | - public function getVersion() |
|
37 | - { |
|
38 | - return "V1"; |
|
39 | - } |
|
36 | + public function getVersion() |
|
37 | + { |
|
38 | + return "V1"; |
|
39 | + } |
|
40 | 40 | |
41 | - public function getDataType() |
|
42 | - { |
|
43 | - return "JSON"; |
|
44 | - } |
|
41 | + public function getDataType() |
|
42 | + { |
|
43 | + return "JSON"; |
|
44 | + } |
|
45 | 45 | |
46 | - public function getType() |
|
47 | - { |
|
48 | - return "pdd.ddk.oauth.goods.pid.query"; |
|
49 | - } |
|
46 | + public function getType() |
|
47 | + { |
|
48 | + return "pdd.ddk.oauth.goods.pid.query"; |
|
49 | + } |
|
50 | 50 | |
51 | - public function setPage($page) |
|
52 | - { |
|
53 | - $this->page = $page; |
|
54 | - } |
|
51 | + public function setPage($page) |
|
52 | + { |
|
53 | + $this->page = $page; |
|
54 | + } |
|
55 | 55 | |
56 | - public function setPageSize($pageSize) |
|
57 | - { |
|
58 | - $this->pageSize = $pageSize; |
|
59 | - } |
|
56 | + public function setPageSize($pageSize) |
|
57 | + { |
|
58 | + $this->pageSize = $pageSize; |
|
59 | + } |
|
60 | 60 | |
61 | - public function setPidList($pidList) |
|
62 | - { |
|
63 | - $this->pidList = $pidList; |
|
64 | - } |
|
61 | + public function setPidList($pidList) |
|
62 | + { |
|
63 | + $this->pidList = $pidList; |
|
64 | + } |
|
65 | 65 | |
66 | 66 | } |