Jelajahi Sumber

wx获取手机号

lizhen_gitee 1 tahun lalu
induk
melakukan
a8db4d36ec
1 mengubah file dengan 3 tambahan dan 3 penghapusan
  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;