微信公众号实现用户管理功能

广告:宝塔Linux面板高效运维的服务器管理软件 点击【 https://www.bt.cn/p/uNLv1L 】立即购买

微信公众号实现用户管理功能

1、设置用户备注名

接口:https://api.weixin.qq.com/cgi-bin/user/info/updateremark?access_token=ACCESS_TOKEN

updateremark.php

<?phprequire_once("../Utils.php");$data = '{    "openid":"o4WmZ0h-4huBUVQUczx2ezaxIL9c",    "remark":"Jhon"}';$url = "https://api.weixin.qq.com/cgi-bin/user/info/updateremark?"    ."access_token=".Utils::get_access_token();$result = Utils::https_request($url, $data);echo $result;
登录后复制

返回:

{"errcode":0,"errmsg":"ok"}
登录后复制登录后复制登录后复制登录后复制2、获取用户基本信息

接口:https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN

userInfp.php

<?phprequire_once("../Utils.php");$openId = "o4WmZ0h-4huBUVQUczx2ezaxIL9c";$url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token="    .Utils::get_access_token()."&openid=".$openId."&lang=zh_CN ";$result = Utils::https_request($url);echo $result;
登录后复制

返回:

{    "subscribe": 1,    "openid": "o4WmZ0h-4huBUVQUczx2ezaxIL9c",    "nickname": "Promise",    "sex": 1,    "language": "zh_CN",    "city": "",    "province": "",    "country": "",    "headimgurl": "http://wx.qlogo.cn/mmopen/Vq7PMkMOaMYgtQNJBrdesiantXGgGkliaoI3StUtnG5DUA1oYaeTlOdjicYHu9EkMvLY2gXf7rHBzGNiaPoDyvmZ0ONEGm7PfGBb/0",    "subscribe_time": 1504708412,    "remark": "Jhon",    "groupid": 0,    "tagid_list": []}
登录后复制3、批量获取用户消息

接口:https://api.weixin.qq.com/cgi-bin/user/info/batchget?access_token=ACCESS_TOKEN

batchget.php

<?phprequire_once("../Utils.php");$data = '{    "user_list": [       {           "openid": "o4WmZ0h-4huBUVQUczx2ezaxIL9c",           "lang": "zh_CN"       }   ]}';$url = "https://api.weixin.qq.com/cgi-bin/user/info/batchget?"    ."access_token=".Utils::get_access_token();$result = Utils::https_request($url, $data);echo $result;
登录后复制

返回:

{    "user_info_list": [        {            "subscribe": 1,            "openid": "o4WmZ0h-4huBUVQUczx2ezaxIL9c",            "nickname": "Promise",            "sex": 1,            "language": "zh_CN",            "city": "",            "province": "",            "country": "",            "headimgurl": "http://wx.qlogo.cn/mmopen/Vq7PMkMOaMYgtQNJBrdesiantXGgGkliaoI3StUtnG5DUA1oYaeTlOdjicYHu9EkMvLY2gXf7rHBzGNiaPoDyvmZ0ONEGm7PfGBb/0",            "subscribe_time": 1504708412,            "remark": "Jhon",            "groupid": 0,            "tagid_list": []        }    ]}
登录后复制4、创建标签

接口:https://api.weixin.qq.com/cgi-bin/tags/create?access_token=ACCESS_TOKEN

tags_create.php

<?php@header('Content-type: text/plain;charset=UTF-8');require_once("../Utils.php");$data = '{    "tag" : {        "name" : "朋友"  }}';$url = "https://api.weixin.qq.com/cgi-bin/tags/create?"    ."access_token=".Utils::get_access_token();$result = Utils::https_request($url, $data);echo $result;
登录后复制

返回:

{    "tag": {        "id": 101,        "name": "朋友"    }}
登录后复制5、获取以创建标签

接口:https://api.weixin.qq.com/cgi-bin/tags/get?access_token=ACCESS_TOKEN

tags_get.php

<?php@header('Content-type: text/plain;charset=UTF-8');require_once("../Utils.php");$url = "https://api.weixin.qq.com/cgi-bin/tags/get?access_token="    .Utils::get_access_token();$result = Utils::https_request($url);echo $result;
登录后复制

返回:

{    "tags": [        {            "id": 2,            "name": "星标组",            "count": 0        },        {            "id": 100,            "name": "同学",            "count": 0        },        {            "id": 101,            "name": "朋友",            "count": 0        }    ]}
登录后复制6、编辑标签

接口:https://api.weixin.qq.com/cgi-bin/tags/update?access_token=ACCESS_TOKEN

tags_update.php

{"errcode":0,"errmsg":"ok"}0
登录后复制

返回:

{"errcode":0,"errmsg":"ok"}
登录后复制登录后复制登录后复制登录后复制7、删除标签

当某个标签下的粉丝超过10w时,后台不可直接删除标签。此时,开发者可以对该标签下的openid列表,先进行取消标签的操作,直到粉丝数不超过10w后,才可直接删除该标签。

接口:https://api.weixin.qq.com/cgi-bin/tags/delete?access_token=ACCESS_TOKEN

tags_delete.php

{"errcode":0,"errmsg":"ok"}2
登录后复制

返回:

{"errcode":0,"errmsg":"ok"}
登录后复制登录后复制登录后复制登录后复制8、批量为用户打标签

标签功能目前支持公众号为用户打上最多20个标签。

接口:https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging?access_token=ACCESS_TOKEN

tags_batchtagging.php

{"errcode":0,"errmsg":"ok"}4
登录后复制

返回结果:

{"errcode":0,"errmsg":"ok"}
登录后复制9、获取标签下粉丝列表

接口:https://api.weixin.qq.com/cgi-bin/user/tag/get?access_token=ACCESS_TOKEN

"next_openid":""//第一个拉取的OPENID,不填默认从头开始拉取

tags_get_user.php

{"errcode":0,"errmsg":"ok"}6
登录后复制

返回:

{"errcode":0,"errmsg":"ok"}7
登录后复制10、获取用户身上的标签列表

接口;https://api.weixin.qq.com/cgi-bin/tags/getidlist?access_token=ACCESS_TOKEN

tags_getidlist.php

{"errcode":0,"errmsg":"ok"}8
登录后复制

返回:

{"errcode":0,"errmsg":"ok"}9
登录后复制

11、批量为用户取消标签

接口:https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging?access_token=ACCESS_TOKEN

tags_batchuntagging.php

<?phprequire_once("../Utils.php");$openId = "o4WmZ0h-4huBUVQUczx2ezaxIL9c";$url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token="    .Utils::get_access_token()."&openid=".$openId."&lang=zh_CN ";$result = Utils::https_request($url);echo $result;0
登录后复制

返回:

{"errcode":0,"errmsg":"ok"}
登录后复制登录后复制登录后复制登录后复制

以上就是微信公众号实现用户管理功能的详细内容,更多请关注9543建站博客其它相关文章!

广告:SSL证书一年128.66元起,点击购买~~~

9543建站博客
一个专注于网站开发、微信开发的技术类纯净博客。

作者头像
admin创始人

肥猫,知名SEO博客站长,14年SEO经验。

上一篇:yii中如何判断数据表是否存在于数据库中
下一篇:已是最新文章

发表评论

关闭广告
关闭广告