@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | |
39 | 39 | public function __construct($options) |
40 | 40 | { |
41 | - $this->host = isset($options['host'])?$options['host']:$this->host; |
|
42 | - $this->pull_route = isset($options['pull_route'])?$options['pull_route']:$this->pull_route; |
|
43 | - $this->push_route = isset($options['push_route'])?$options['push_route']:$this->push_route; |
|
44 | - $this->signature_key = isset($options['signature_key'])?$options['signature_key']:$this->signature_key; |
|
45 | - $this->token = isset($options['token'])?$options['token']:$this->token; |
|
41 | + $this->host = isset($options['host']) ? $options['host'] : $this->host; |
|
42 | + $this->pull_route = isset($options['pull_route']) ? $options['pull_route'] : $this->pull_route; |
|
43 | + $this->push_route = isset($options['push_route']) ? $options['push_route'] : $this->push_route; |
|
44 | + $this->signature_key = isset($options['signature_key']) ? $options['signature_key'] : $this->signature_key; |
|
45 | + $this->token = isset($options['token']) ? $options['token'] : $this->token; |
|
46 | 46 | $this->timestamp = time(); |
47 | 47 | } |
48 | 48 | |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function pushData($data) |
71 | 71 | { |
72 | - if(!isset($data['clue_convert_state']) || !isset($data['clue_id'])){ |
|
72 | + if (!isset($data['clue_convert_state']) || !isset($data['clue_id'])) { |
|
73 | 73 | throw new FeiYuException("Upload data is missing the necessary parameters", 1); |
74 | 74 | } |
75 | - if(!is_numeric($data['clue_convert_state'])){ |
|
75 | + if (!is_numeric($data['clue_convert_state'])) { |
|
76 | 76 | throw new FeiYuException("'clue_convert_state' must be a numeric type", 1); |
77 | 77 | } |
78 | - $data['clue_convert_state'] = (int)$data['clue_convert_state']; |
|
78 | + $data['clue_convert_state'] = (int) $data['clue_convert_state']; |
|
79 | 79 | $this->push_data = json_encode([ |
80 | 80 | 'source' => 0, |
81 | 81 | 'data' => [ |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | $page++; |
116 | - } while (($page-1)*($this->page_size) < $this->res_data['count']); |
|
116 | + } while (($page - 1) * ($this->page_size) < $this->res_data['count']); |
|
117 | 117 | |
118 | 118 | return true; |
119 | 119 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | protected function encryptData() |
126 | 126 | { |
127 | 127 | // 拼接中的空格很重要 |
128 | - if($this->fetch_route == $this->pull_route){ |
|
128 | + if ($this->fetch_route == $this->pull_route) { |
|
129 | 129 | $data = $this->fetch_route.'?start_time='.$this->start_time.'&end_time='.$this->end_time.' '.$this->timestamp; |
130 | 130 | } else { |
131 | 131 | $data = $this->fetch_route.' '.$this->timestamp; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | { |
144 | 144 | $this->encryptData(); |
145 | 145 | $ch = curl_init(); |
146 | - if(!$ch){ |
|
146 | + if (!$ch) { |
|
147 | 147 | throw new FeiYuException('cURL init failed', 1); |
148 | 148 | } |
149 | 149 | curl_setopt($ch, CURLOPT_URL, $this->host.$this->fetch_route.'?page='.$page.'&page_size='.$this->page_size.'&start_time='.$this->start_time.'&end_time='.$this->end_time); |
@@ -151,23 +151,23 @@ discard block |
||
151 | 151 | curl_setopt($ch, CURLOPT_TIMEOUT, 5); |
152 | 152 | curl_setopt($ch, CURLOPT_HTTPHEADER, [ |
153 | 153 | 'Content-Type: application/json;charset=UTF-8', |
154 | - 'Signature: ' . $this->signature, |
|
155 | - 'Timestamp: ' . $this->timestamp, |
|
156 | - 'Access-Token: ' . $this->token, |
|
154 | + 'Signature: '.$this->signature, |
|
155 | + 'Timestamp: '.$this->timestamp, |
|
156 | + 'Access-Token: '.$this->token, |
|
157 | 157 | ]); |
158 | - if($this->fetch_route == $this->push_route){ |
|
158 | + if ($this->fetch_route == $this->push_route) { |
|
159 | 159 | curl_setopt($ch, CURLOPT_POST, true); |
160 | 160 | curl_setopt($ch, CURLOPT_POSTFIELDS, $this->push_data); |
161 | 161 | } |
162 | 162 | $output = curl_exec($ch); |
163 | 163 | $error = curl_error($ch); |
164 | 164 | curl_close($ch); |
165 | - if($error != ''){ |
|
165 | + if ($error != '') { |
|
166 | 166 | throw new FeiYuException($error, 1); |
167 | 167 | } |
168 | 168 | $this->res_data = json_decode($output, true); |
169 | - if($this->res_data['status'] != 'success'){ |
|
170 | - if(is_array($this->res_data['msg'])){ |
|
169 | + if ($this->res_data['status'] != 'success') { |
|
170 | + if (is_array($this->res_data['msg'])) { |
|
171 | 171 | throw new FeiYuException(json_encode($this->res_data['msg']), 1); |
172 | 172 | } |
173 | 173 | throw new FeiYuException($this->res_data['msg'], 1); |