争怎路由网:是一个主要分享无线路由器安装设置经验的网站,汇总WiFi常见问题的解决方法。

微信公众号完成用户管理技巧

时间:2022-9-12作者:未知来源:争怎路由网人气:

微信(WeChat)是腾讯公司于2011年1月21日推出的一个为智能终端提供即时通讯服务的免费应用程序,由张小龙所带领的腾讯广州研发中心产品团队打造 [2] 。微信支持跨通信运营商、跨操作系统平台通过网络快速发送免费(需消耗少量网络流量)语音短信、视频、图片和文字,同时,也可以使用通过共享流媒体内容的资料和基于位置的社交插件“摇一摇”、“漂流瓶”、“朋友圈”、”公众平台“、”语音记事本“等服务插件。

1、设置用户备注名

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

updateremark.php

<?php
require_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

<?php
require_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

<?php
require_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

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

返回:

{"errcode":0,"errmsg":"ok"}

7、删除标签

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

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

tags_delete.php

<?php
@header('Content-type: text/plain;charset=UTF-8');
require_once("../Utils.php");
$data = '{
    "tag" : {
        "id" : 101
    }
}';
$url = "https://api.weixin.qq.com/cgi-bin/tags/delete?"
    ."access_token=".Utils::get_access_token();
$result = Utils::https_request($url, $data);
echo $result;

返回:

{"errcode":0,"errmsg":"ok"}

8、批量为用户打标签

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

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

tags_batchtagging.php

<?php
@header('Content-type: text/plain;charset=UTF-8');
require_once("../Utils.php");
$data = '{
    "openid_list" : [
        "o4WmZ0h-4huBUVQUczx2ezaxIL9c"
    ],
  "tagid" : 100
}';
$url = "https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging?"
    ."access_token=".Utils::get_access_token();
$result = Utils::https_request($url, $data);
echo $result;

返回结果:

{"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

<?php
@header('Content-type: text/plain;charset=UTF-8');
require_once("../Utils.php");
$data = '{
  "tagid" : 100,
  "next_openid":""
}';
$url = "https://api.weixin.qq.com/cgi-bin/user/tag/get?"
    ."access_token=".Utils::get_access_token();
$result = Utils::https_request($url, $data);
echo $result;

返回:

{
    "count": 1,
    "data": {
        "openid": [
            "o4WmZ0h-4huBUVQUczx2ezaxIL9c"
        ]
    },
    "next_openid": "o4WmZ0h-4huBUVQUczx2ezaxIL9c"
}

10、获取用户身上的标签列表

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

tags_getidlist.php

<?php
@header('Content-type: text/plain;charset=UTF-8');
require_once("../Utils.php");
$data = '{
  "openid" : "o4WmZ0h-4huBUVQUczx2ezaxIL9c"
}';
$url = "https://api.weixin.qq.com/cgi-bin/tags/getidlist?"
    ."access_token=".Utils::get_access_token();
$result = Utils::https_request($url, $data);
echo $result;

返回:

{
    "tagid_list": [
        100
    ]
}

11、批量为用户取消标签

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

tags_batchuntagging.php

<?php
@header('Content-type: text/plain;charset=UTF-8');
require_once("../Utils.php");
$data = '{
    "openid_list" : [
        "o4WmZ0h-4huBUVQUczx2ezaxIL9c"
    ],
  "tagid" : 100
}';
$url = "https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging?"
    ."access_token=".Utils::get_access_token();
$result = Utils::https_request($url, $data);
echo $result;

返回:

{"errcode":0,"errmsg":"ok"}

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


微信提供公众平台、朋友圈、消息推送等功能,用户可以通过“摇一摇”、“搜索号码”、“附近的人”、扫二维码方式添加好友和关注公众平台,同时微信将内容分享给好友以及将用户看到的精彩内容分享到微信朋友圈。



关键词:微信公众号完成用户管理技巧




Copyright © 2012-2018 争怎路由网(http://www.zhengzen.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版