소스 검색

wx获取手机号

lizhen_gitee 1 년 전
부모
커밋
a8db4d36ec
1개의 변경된 파일3개의 추가작업 그리고 3개의 파일을 삭제
  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;