Explorar o código

wx获取手机号

lizhen_gitee hai 1 ano
pai
achega
a8db4d36ec
Modificáronse 1 ficheiros con 3 adicións e 3 borrados
  1. 3 3
      application/common/library/Wechat.php

+ 3 - 3
application/common/library/Wechat.php

@@ -132,13 +132,13 @@ class Wechat
 
     public function getPhoneNumber($code = ''){
         $accessToken = $this->getPublicAccessToken();
+
         $getPhoneUrl = 'https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token='.$accessToken;
 
-        $params = [
-            'code'=>$code
-        ];
+        $params = json_encode(['code'=>$code]);
 
         $ret = Http::sendRequest($getPhoneUrl, $params, 'POST');
+
         if ($ret['ret']) {
             $ar = json_decode($ret['msg'], true);
             return $ar;