365体育备用网址报道6.5.1猎取用户基本信息_365体育备用网址官网资讯

我们可通过OpenID来猎取用户基本信息。
猎取用户信息的接口如下:
https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN
该接口的参数说明如表6-13所示:

表6-13猎取用户信息要求参数说明
猎取用户基本信息的代码实现如下所示:

 1 PHP" style="box-sizing: inherit; margin: 0px; padding: 0px;"><?php
 2 $access_token = "QfUKtidNK0z-WA9C38JIncULipiunLfKpic1rmcnPOCs4UuZ7ek7PvjM5mLXnkJH7d5u2vX2q7UY9wurrJRjFrnIi4O6BkDwSmfE3wv1-ToSrEXGzwOpzgc8SSw74tNHDAUbACAWTN";
 3 
 4 $openid = "oiPuduGV7gJ_MOSfAWpVmhhgXh-U";
 5 $url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=$access_token&openid=$openid&lang=zh_CN";
 6 $output = https_request($url);
 7 var_dump($output);
 8 
 9 function https_request($url, $data = null)
10 {
11     $curl = curl_init();
12     curl_setopt($curl, CURLOPT_URL, $url);
13     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
14     curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
15     if (!empty($data)){
16         curl_setopt($curl, CURLOPT_POST, 1);
17         curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
18     }
19     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
20     $output = curl_exec($curl);
21     curl_close($curl);
22     return $output;
23 }
24 ?>

上述代码执行后,返回结果如下:

{
    "subscribe":1,
    "openid":"oiPuduGV7gJ_MOSfAWpVmhhgXh-U",
    "nickname":"喵了个咪",
    "sex":1,
    "language":"zh_CN",
    "city":"深圳",
    "province":"广东",
    "country":"365体育备用网址",
    "headimgurl":"http://wx.qlogo.cn/mmopen/AkcGLGLkeINKqK5nbT6DtrL9XY47H1niaRLBq04jrPSzcIlbWVMgiaUbgVnAWVcQJz63mtyNF4YjdpiaBLymaFmKCheBpQyu9BR/0",
    "subscribe_time":1468461486,
    "unionid":"o6_bmasdasdsad6_2sgVt7hMZOPfL",
    "remark":"fangbei",
    "groupid":2,
    "tagid_list":[
        2,
        102,
        105
    ]
}

上述数据的参数说明如表6-14所示:

表6-14猎取用户信息结果参数说明

------分隔线----------------------------

公布评论 (179人察看0条评论)
请自觉遵守互联网相关的政策法规,严禁公布色情、暴力、反动的言论。
用户名: 验证码: 点击我更换鸿运国际手机欢迎你
最新评论