Skip to content

Commit ccd6533

Browse files
committed
[更新]php版本语法兼容调整
1 parent baf0ec2 commit ccd6533

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

Wechat/Lib/Tools.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static public function getSignature($data, $method = "sha1")
6868
return false;
6969
}
7070
ksort($data);
71-
$params = [];
71+
$params = array();
7272
foreach ($data as $key => $value) {
7373
$params[] = "{$key}={$value}";
7474
}
@@ -124,13 +124,12 @@ static private function _data_to_xml($data, $item = 'item', $id = 'id', $content
124124
} else {
125125
$content .= '<![CDATA[' . preg_replace("/[\\x00-\\x08\\x0b-\\x0c\\x0e-\\x1f]/", '', $val) . ']]>';
126126
}
127-
list($_key,) = explode(' ', $key . ' ');
127+
list($_key, ) = explode(' ', $key . ' ');
128128
$content .= "</$_key>";
129129
}
130130
return $content;
131131
}
132132

133-
134133
/**
135134
* 将xml转为array
136135
* @param string $xml
@@ -167,7 +166,7 @@ static public function httpGet($url)
167166
curl_setopt($curl, CURLOPT_URL, $url);
168167
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
169168
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
170-
list($content, $status) = [curl_exec($curl), curl_getinfo($curl), curl_close($curl)];
169+
list($content, $status) = array(curl_exec($curl), curl_getinfo($curl), curl_close($curl));
171170
return (intval($status["http_code"]) === 200) ? $content : false;
172171
}
173172

@@ -187,7 +186,7 @@ static public function httpPost($url, $data)
187186
curl_setopt($curl, CURLOPT_HEADER, false);
188187
curl_setopt($curl, CURLOPT_POST, true);
189188
curl_setopt($curl, CURLOPT_POSTFIELDS, self::_buildPost($data));
190-
list($content, $status) = [curl_exec($curl), curl_getinfo($curl), curl_close($curl)];
189+
list($content, $status) = array(curl_exec($curl), curl_getinfo($curl), curl_close($curl));
191190
return (intval($status["http_code"]) === 200) ? $content : false;
192191
}
193192

@@ -219,7 +218,7 @@ static public function httpsPost($url, $data, $ssl_cer = null, $ssl_key = null,
219218
}
220219
curl_setopt($curl, CURLOPT_POST, true);
221220
curl_setopt($curl, CURLOPT_POSTFIELDS, self::_buildPost($data));
222-
list($content, $status) = [curl_exec($curl), curl_getinfo($curl), curl_close($curl)];
221+
list($content, $status) = array(curl_exec($curl), curl_getinfo($curl), curl_close($curl));
223222
return (intval($status["http_code"]) === 200) ? $content : false;
224223
}
225224

@@ -247,7 +246,7 @@ static private function _buildPost(&$data)
247246
*/
248247
static public function getAddress()
249248
{
250-
foreach (['HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'HTTP_X_CLIENT_IP', 'HTTP_X_CLUSTER_CLIENT_IP', 'REMOTE_ADDR'] as $header) {
249+
foreach (array('HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'HTTP_X_CLIENT_IP', 'HTTP_X_CLUSTER_CLIENT_IP', 'REMOTE_ADDR') as $header) {
251250
if (!isset($_SERVER[$header]) || ($spoof = $_SERVER[$header]) === null) {
252251
continue;
253252
}

Wechat/WechatMedia.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
*/
2727
class WechatMedia extends Common
2828
{
29+
2930
const MEDIA_UPLOAD_URL = '/media/upload?';
3031
const MEDIA_UPLOADIMG_URL = '/media/uploadimg?';
3132
const MEDIA_GET_URL = '/media/get?';
@@ -120,7 +121,7 @@ public function getMediaWithHttpInfo($media_id, $is_video = false)
120121
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1);
121122
$sContent = curl_exec($oCurl);
122123
$aStatus = curl_getinfo($oCurl);
123-
$result = [];
124+
$result = array();
124125
if (intval($aStatus["http_code"]) !== 200) {
125126
return false;
126127
}
@@ -181,7 +182,7 @@ public function uploadImg($data)
181182
* @param array $video_info 视频信息数组,非视频素材不需要提供 array('title'=>'视频标题','introduction'=>'描述')
182183
* @return bool|array
183184
*/
184-
public function uploadForeverMedia($data, $type, $is_video = false, $video_info = [])
185+
public function uploadForeverMedia($data, $type, $is_video = false, $video_info = array())
185186
{
186187
if (!$this->access_token && !$this->getAccessToken()) {
187188
return false;
@@ -269,7 +270,7 @@ public function getForeverMedia($media_id, $is_video = false)
269270
if (!$this->access_token && !$this->getAccessToken()) {
270271
return false;
271272
}
272-
$data = ['media_id' => $media_id];
273+
$data = array('media_id' => $media_id);
273274
$result = Tools::httpPost(self::API_URL_PREFIX . self::MEDIA_FOREVER_GET_URL . "access_token={$this->access_token}", Tools::json_encode($data));
274275
if ($result) {
275276
if (is_string($result) && ($json = json_decode($result, true))) {
@@ -295,7 +296,7 @@ public function delForeverMedia($media_id)
295296
if (!$this->access_token && !$this->getAccessToken()) {
296297
return false;
297298
}
298-
$data = ['media_id' => $media_id];
299+
$data = array('media_id' => $media_id);
299300
$result = Tools::httpPost(self::API_URL_PREFIX . self::MEDIA_FOREVER_DEL_URL . "access_token={$this->access_token}", Tools::json_encode($data));
300301
if ($result) {
301302
$json = json_decode($result, true);
@@ -327,7 +328,7 @@ public function getForeverList($type, $offset, $count)
327328
if (!$this->access_token && !$this->getAccessToken()) {
328329
return false;
329330
}
330-
$data = ['type' => $type, 'offset' => $offset, 'count' => $count,];
331+
$data = array('type' => $type, 'offset' => $offset, 'count' => $count);
331332
$result = Tools::httpPost(self::API_URL_PREFIX . self::MEDIA_FOREVER_BATCHGET_URL . "access_token={$this->access_token}", Tools::json_encode($data));
332333
if ($result) {
333334
$json = json_decode($result, true);

0 commit comments

Comments
 (0)