您现在的位置: 365建站网 > 建站教程 > 微信公众平台开发 > 6.4.1获取用户列表

6.4.1获取用户列表

此节有 292 人学习过     参与评论

接口调用请求说明如下:
https://api.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN&next_openid=NEXT_OPENID
上述接口参数如表6-11所示:

表6-11获取用户列表请求参数说明
构造请求列表如下:
https://api.weixin.qq.com/cgi-bin/user/get?access_token=5ic8RoqZd7IBUtE0aGXUhcdKBnrwlO1iqtvyJJUgIcDcopJIH7x90QH4yiK_z08fqp4WOD7kfKPDtET29BRYNZO-sSIITaxIj4u72LYAYcFH6t1fiSVzjUuqYWOtHiw0LGDorxx5Qj6SN0Z7GtYGTA
获取用户列表的代码实现如下所示:

1 <?php
 2 $access_token = "Ti2h3ujhxdCYlHZKfhNEyUFFTmGTTCYISHz8QyJnPvI29IhfFrd53Xl6_jw3Yi3xAVNv_TSR9mfkhrBV-nm7WZa-NA2p3v_cp0B3dRTLmbCOSwhMcFArrISEcxUGBVw_XFHhAAAQYA";
 3 
 4 $url = "https://api.weixin.qq.com/cgi-bin/user/get?access_token=$access_token";
 5 $result = https_request($url);
 6 var_dump($result);
 7 
 8 function https_request($url, $data = null)
 9 {
10     $curl = curl_init();
11     curl_setopt($curl, CURLOPT_URL, $url);
12     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
13     curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
14     if (!empty($data)){
15         curl_setopt($curl, CURLOPT_POST, 1);
16         curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
17     }
18     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
19     $output = curl_exec($curl);
20     curl_close($curl);
21     return $output;
22 }
23 ?>

代码执行后,返回结果如下所示:

{
    "total":5701,
    "count":5701,
    "data":{
        "openid":[
            "oiPuduD1wqM1DfT8bEMcvm5AS94M",
            "oiPuduOCz49SfENckHW-3HhzSVMc",
            "oiPuduNiFBwG-YKkBe4mIYIRausw",
            "oiPuduB-nmupLByqdsgC6zXoGX5k",
            "oiPuduNCi7NFlhVnyjgK403DJgug",
            "oiPuduLG154WOgpWWB20RiTORnx0"
        ]
    },
    "next_openid":"oiPuduLG154WOgpWWB20RiTORnx0"
}

返回结果参数说明如表6-12所示:

表6-12获取用户列表结果参数说明

如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛


发表评论 (292人查看0条评论)
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名: 验证码: 点击我更换图片
最新评论
------分隔线----------------------------
微信公众平台开发目录