From 3b7041b8a18829a928084ed6f0f16c911ed3170c Mon Sep 17 00:00:00 2001 From: hzg0403 Date: Wed, 28 Dec 2016 11:40:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=8E=B7=E5=8F=96=E5=85=B3?= =?UTF-8?q?=E6=B3=A8=E8=80=85=E8=AF=A6=E7=BB=86=E4=BF=A1=E6=81=AF=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E5=87=BA=E7=8E=B0=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 如用户信息某一字段存在特殊字符,这导致JSON_DECODE返回NULL,现对微信服务器请求结果进行编码替换后在进行解析。 --- Wechat/WechatUser.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Wechat/WechatUser.php b/Wechat/WechatUser.php index 9205968..4c72515 100644 --- a/Wechat/WechatUser.php +++ b/Wechat/WechatUser.php @@ -93,6 +93,7 @@ public function getUserInfo($openid) { } $result = Tools::httpGet(self::API_URL_PREFIX . self::USER_INFO_URL . "access_token={$this->access_token}&openid={$openid}"); if ($result) { + $result = substr(str_replace('\"', '"', json_encode($result)), 1, -1); $json = json_decode($result, true); if (isset($json['errcode'])) { $this->errCode = $json['errcode'];