@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | /** |
10 | 10 | * SDK版本号 |
11 | 11 | */ |
12 | - public static $VERSION="0.0.2"; |
|
12 | + public static $VERSION = "0.0.2"; |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * 接口超时时间 |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @param $clientId 开放平台分配的clientId |
33 | 33 | * @param $clientSecret 开放平台分配的clientSecret |
34 | 34 | */ |
35 | - public function __construct($clientId, $clientSecret){ |
|
35 | + public function __construct($clientId, $clientSecret) { |
|
36 | 36 | $this->clientId = $clientId; |
37 | 37 | $this->clientSecret = $clientSecret; |
38 | 38 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param $access_token 表示调用接口的授权码 |
44 | 44 | * @return 接口返回信息 |
45 | 45 | */ |
46 | - public function syncInvoke($request, $access_token = ""){ |
|
46 | + public function syncInvoke($request, $access_token = "") { |
|
47 | 47 | |
48 | 48 | $params = $this->uniqueParams($request, $access_token); |
49 | 49 | |
@@ -61,20 +61,20 @@ discard block |
||
61 | 61 | * @param $request请求参数 $access_token 授权参数 |
62 | 62 | * @return 构造后的所有参数 |
63 | 63 | */ |
64 | - private function uniqueParams($request, $access_token){ |
|
64 | + private function uniqueParams($request, $access_token) { |
|
65 | 65 | |
66 | 66 | $params = $request->getParamsMap(); |
67 | 67 | |
68 | 68 | $params['client_id'] = $this->clientId; |
69 | 69 | |
70 | - if($access_token){ |
|
70 | + if ($access_token) { |
|
71 | 71 | $params['access_token'] = $access_token; |
72 | 72 | } |
73 | 73 | |
74 | 74 | //把boolean转为true 和 false |
75 | - foreach ($params as $key=>$val){ |
|
76 | - if(is_bool($val)){ |
|
77 | - $params[$key] = $val?"true":"false"; |
|
75 | + foreach ($params as $key=>$val) { |
|
76 | + if (is_bool($val)) { |
|
77 | + $params[$key] = $val ? "true" : "false"; |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -85,14 +85,14 @@ discard block |
||
85 | 85 | * @param $request 请求的参数 |
86 | 86 | * @return 返回md5后的sign值 |
87 | 87 | */ |
88 | - private function makeSign($params){ |
|
88 | + private function makeSign($params) { |
|
89 | 89 | |
90 | 90 | //签名步骤一:按字典序排序参数 |
91 | 91 | ksort($params); |
92 | 92 | $string = $this->toUrlParams($params); |
93 | 93 | |
94 | 94 | //签名步骤二:在string首尾加上client_secret |
95 | - $string = $this->clientSecret . $string . $this->clientSecret; |
|
95 | + $string = $this->clientSecret.$string.$this->clientSecret; |
|
96 | 96 | |
97 | 97 | //签名步骤三:MD5加密 |
98 | 98 | $string = md5($string); |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | $buff = ""; |
112 | 112 | foreach ($params as $k => $v) |
113 | 113 | { |
114 | - if($k != "sign" && $v !== "" && !is_array($v)){ |
|
115 | - $buff .= $k . $v ; |
|
114 | + if ($k != "sign" && $v !== "" && !is_array($v)) { |
|
115 | + $buff .= $k.$v; |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | return $buff; |
119 | 119 | } |
120 | 120 | |
121 | - private function postCurl($params){ |
|
121 | + private function postCurl($params) { |
|
122 | 122 | $ch = curl_init(); |
123 | 123 | $curlVersion = curl_version(); |
124 | 124 | $ua = "PopSDK/".self::$VERSION." (".PHP_OS.") PHP/".PHP_VERSION." CURL/".$curlVersion['version']." " |
@@ -127,12 +127,12 @@ discard block |
||
127 | 127 | //设置超时 |
128 | 128 | curl_setopt($ch, CURLOPT_TIMEOUT, self::$SECONDS); |
129 | 129 | |
130 | - curl_setopt($ch,CURLOPT_URL, $this->apiServerUrl); |
|
131 | - curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false); |
|
132 | - curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0);//严格校验 |
|
133 | - curl_setopt($ch,CURLOPT_USERAGENT, $ua); |
|
130 | + curl_setopt($ch, CURLOPT_URL, $this->apiServerUrl); |
|
131 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
|
132 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); //严格校验 |
|
133 | + curl_setopt($ch, CURLOPT_USERAGENT, $ua); |
|
134 | 134 | //设置header |
135 | - curl_setopt($ch, CURLOPT_HEADER,false); |
|
135 | + curl_setopt($ch, CURLOPT_HEADER, false); |
|
136 | 136 | |
137 | 137 | //设置header |
138 | 138 | $headers = array( |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
156 | 156 | |
157 | 157 | //返回结果 |
158 | - if($raw_response){ |
|
158 | + if ($raw_response) { |
|
159 | 159 | curl_close($ch); |
160 | 160 | |
161 | 161 | $response = new PopHttpResponse(); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $response->setBody($raw_response); |
164 | 164 | |
165 | 165 | return $response; |
166 | - } else { |
|
166 | + }else { |
|
167 | 167 | $error = curl_errno($ch); |
168 | 168 | curl_close($ch); |
169 | 169 | throw new PopHttpException("curl出错,错误码:$error"); |
@@ -6,7 +6,7 @@ |
||
6 | 6 | */ |
7 | 7 | class PopHttpException extends \Exception |
8 | 8 | { |
9 | - public function errorMessage(){ |
|
9 | + public function errorMessage() { |
|
10 | 10 | return $this->getMessage(); |
11 | 11 | } |
12 | 12 | } |
13 | 13 | \ No newline at end of file |
@@ -23,19 +23,19 @@ |
||
23 | 23 | $data = []; |
24 | 24 | $class = new ReflectionClass($this); |
25 | 25 | $properties = $class->getProperties(); |
26 | - foreach ($properties as $prop){ |
|
26 | + foreach ($properties as $prop) { |
|
27 | 27 | $doc = $this->parseDoc($prop->getDocComment()); |
28 | 28 | $prop->setAccessible(true); |
29 | - if ($doc != null && count($doc) == 2){ |
|
29 | + if ($doc != null && count($doc) == 2) { |
|
30 | 30 | $value = $prop->getValue($this); |
31 | - if(is_object($value)){ |
|
32 | - $value = json_decode(json_encode($value),true); |
|
31 | + if (is_object($value)) { |
|
32 | + $value = json_decode(json_encode($value), true); |
|
33 | 33 | } |
34 | - if(!is_null($value)){ |
|
34 | + if (!is_null($value)) { |
|
35 | 35 | $data[$doc[1]] = $value; |
36 | 36 | } |
37 | 37 | } |
38 | 38 | } |
39 | - return empty($data)?null:$data; |
|
39 | + return empty($data) ?null:$data; |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | \ No newline at end of file |
@@ -12,14 +12,14 @@ |
||
12 | 12 | $request = new PddWmsOrderCancelRequest(); |
13 | 13 | |
14 | 14 | $request->setRequest(); |
15 | -try{ |
|
15 | +try { |
|
16 | 16 | $response = $client->syncInvoke($request); |
17 | -} catch(Com\Pdd\Pop\Sdk\PopHttpException $e){ |
|
17 | +} catch (Com\Pdd\Pop\Sdk\PopHttpException $e) { |
|
18 | 18 | echo $e->getMessage(); |
19 | 19 | exit; |
20 | 20 | } |
21 | 21 | $content = $response->getContent(); |
22 | -if(isset($content['error_response'])){ |
|
22 | +if (isset($content['error_response'])) { |
|
23 | 23 | echo "异常返回"; |
24 | 24 | } |
25 | -echo json_encode($content,JSON_UNESCAPED_UNICODE); |
|
26 | 25 | \ No newline at end of file |
26 | +echo json_encode($content, JSON_UNESCAPED_UNICODE); |
|
27 | 27 | \ No newline at end of file |
@@ -16,14 +16,14 @@ |
||
16 | 16 | $request->setCreatedAtLte(1); |
17 | 17 | $request->setPageNum(1); |
18 | 18 | $request->setPageSize(1); |
19 | -try{ |
|
19 | +try { |
|
20 | 20 | $response = $client->syncInvoke($request); |
21 | -} catch(Com\Pdd\Pop\Sdk\PopHttpException $e){ |
|
21 | +} catch (Com\Pdd\Pop\Sdk\PopHttpException $e) { |
|
22 | 22 | echo $e->getMessage(); |
23 | 23 | exit; |
24 | 24 | } |
25 | 25 | $content = $response->getContent(); |
26 | -if(isset($content['error_response'])){ |
|
26 | +if (isset($content['error_response'])) { |
|
27 | 27 | echo "异常返回"; |
28 | 28 | } |
29 | -echo json_encode($content,JSON_UNESCAPED_UNICODE); |
|
30 | 29 | \ No newline at end of file |
30 | +echo json_encode($content, JSON_UNESCAPED_UNICODE); |
|
31 | 31 | \ No newline at end of file |
@@ -14,14 +14,14 @@ |
||
14 | 14 | $request->setCatId(1); |
15 | 15 | $request->setKeyProp(); |
16 | 16 | $request->setSpuName('str'); |
17 | -try{ |
|
17 | +try { |
|
18 | 18 | $response = $client->syncInvoke($request); |
19 | -} catch(Com\Pdd\Pop\Sdk\PopHttpException $e){ |
|
19 | +} catch (Com\Pdd\Pop\Sdk\PopHttpException $e) { |
|
20 | 20 | echo $e->getMessage(); |
21 | 21 | exit; |
22 | 22 | } |
23 | 23 | $content = $response->getContent(); |
24 | -if(isset($content['error_response'])){ |
|
24 | +if (isset($content['error_response'])) { |
|
25 | 25 | echo "异常返回"; |
26 | 26 | } |
27 | -echo json_encode($content,JSON_UNESCAPED_UNICODE); |
|
28 | 27 | \ No newline at end of file |
28 | +echo json_encode($content, JSON_UNESCAPED_UNICODE); |
|
29 | 29 | \ No newline at end of file |
@@ -19,14 +19,14 @@ |
||
19 | 19 | $request->setComplainContent('str'); |
20 | 20 | $request->setComplainAttachmentList(array('str')); |
21 | 21 | $request->setComplainType(1); |
22 | -try{ |
|
22 | +try { |
|
23 | 23 | $response = $client->syncInvoke($request); |
24 | -} catch(Com\Pdd\Pop\Sdk\PopHttpException $e){ |
|
24 | +} catch (Com\Pdd\Pop\Sdk\PopHttpException $e) { |
|
25 | 25 | echo $e->getMessage(); |
26 | 26 | exit; |
27 | 27 | } |
28 | 28 | $content = $response->getContent(); |
29 | -if(isset($content['error_response'])){ |
|
29 | +if (isset($content['error_response'])) { |
|
30 | 30 | echo "异常返回"; |
31 | 31 | } |
32 | -echo json_encode($content,JSON_UNESCAPED_UNICODE); |
|
33 | 32 | \ No newline at end of file |
33 | +echo json_encode($content, JSON_UNESCAPED_UNICODE); |
|
34 | 34 | \ No newline at end of file |
@@ -12,14 +12,14 @@ |
||
12 | 12 | $request = new PddOpenDecryptBatchRequest(); |
13 | 13 | |
14 | 14 | $request->setDataList(); |
15 | -try{ |
|
15 | +try { |
|
16 | 16 | $response = $client->syncInvoke($request); |
17 | -} catch(Com\Pdd\Pop\Sdk\PopHttpException $e){ |
|
17 | +} catch (Com\Pdd\Pop\Sdk\PopHttpException $e) { |
|
18 | 18 | echo $e->getMessage(); |
19 | 19 | exit; |
20 | 20 | } |
21 | 21 | $content = $response->getContent(); |
22 | -if(isset($content['error_response'])){ |
|
22 | +if (isset($content['error_response'])) { |
|
23 | 23 | echo "异常返回"; |
24 | 24 | } |
25 | -echo json_encode($content,JSON_UNESCAPED_UNICODE); |
|
26 | 25 | \ No newline at end of file |
26 | +echo json_encode($content, JSON_UNESCAPED_UNICODE); |
|
27 | 27 | \ No newline at end of file |
@@ -16,14 +16,14 @@ |
||
16 | 16 | $request->setRejectReason('str'); |
17 | 17 | $request->setSerialNo('str'); |
18 | 18 | $request->setStatus(1); |
19 | -try{ |
|
19 | +try { |
|
20 | 20 | $response = $client->syncInvoke($request); |
21 | -} catch(Com\Pdd\Pop\Sdk\PopHttpException $e){ |
|
21 | +} catch (Com\Pdd\Pop\Sdk\PopHttpException $e) { |
|
22 | 22 | echo $e->getMessage(); |
23 | 23 | exit; |
24 | 24 | } |
25 | 25 | $content = $response->getContent(); |
26 | -if(isset($content['error_response'])){ |
|
26 | +if (isset($content['error_response'])) { |
|
27 | 27 | echo "异常返回"; |
28 | 28 | } |
29 | -echo json_encode($content,JSON_UNESCAPED_UNICODE); |
|
30 | 29 | \ No newline at end of file |
30 | +echo json_encode($content, JSON_UNESCAPED_UNICODE); |
|
31 | 31 | \ No newline at end of file |