zoukankan      html  css  js  c++  java
  • 高级接口--用户标签管理

    官方文档

    官文中是标签管理。

    创建标签:

    def create_tag(access_token,name):
        # groups
        create_url = 'https://api.weixin.qq.com/cgi-bin/tags/create?access_token=%s'% access_token
    #
    create_url = 'https://api.weixin.qq.com/cgi-bin/tags/create?access_token=%s'% access_token
    # postData={'group':{"name":name}}

    postData ={ "tag" : { "name" : name } }
        response = requests.post(create_url,json.dumps(postData,ensure_ascii=False).encode('utf-8'))
        return json.loads(response.text,encoding='utf-8')

    获取公众号已创建的标签

    def query_tags(access_token):
        query_url ='https://api.weixin.qq.com/cgi-bin/tags/get?access_token=%s'% access_token
        response = requests.get(query_url)
        return json.loads(response.text,encoding='utf-8'

    编辑标签

    def update_tag(access_toke,postData):
        '''{   "tag" : {     "id" : 134,     "name" : "广东人"   } } '''
        update_url='https://api.weixin.qq.com/cgi-bin/tags/update?access_token=%s'%access_token
        postData = json.dumps(postData,ensure_ascii=False).encode('utf-8')
        response = requests.post(update_url, postData)
        return json.loads(response.text,encoding='utf-8')

    获取用户身上的标签列表

    def query_usertags(access_token,openid):
        query_url='https://api.weixin.qq.com/cgi-bin/tags/getidlist?access_token=%s'% access_token
        postData ={
            'openid':openid
        }
        postData = json.dumps(postData, ensure_ascii=False).encode('utf-8')
        response = requests.post(query_url, postData)
        return json.loads(response.text,encoding='utf-8')

    删除标签

    def delete_tag(access_token,tag_id):
        delete_url ='https://api.weixin.qq.com/cgi-bin/tags/delete?access_token=%s'% access_token
        postData =json.dumps({"tag":{ "id" : tag_id } },ensure_ascii=False).encode('utf-8')
        response = requests.post(delete_url, postData)
        return json.loads(response.text, encoding='utf-8')

    批量给用户列表打标签

    def batch_packagetag(access_token,openids,tag_id):
        package_url ='https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging?access_token=%s'% access_token
        postData ={
        "openid_list" :openids,
        "tagid" : tag_id
     }
        postData = json.dumps(postData)
        response = requests.post(package_url, postData)
        return json.loads(response.text, encoding='utf-8')

    批量取消用户列表标签

    def batch_untag(accesss_token,openids,tag_id):
        untag_url = 'https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging?access_token=%s' % access_token
        postData = {
            "openid_list": openids,
            "tagid": tag_id
        }
        postData = json.dumps(postData)
        response = requests.post(untag_url, postData)
        return json.loads(response.text, encoding='utf-8')

    获取标签下的粉丝列表:

    def get_tag_fans(access_token,tag_id,next_openid=''):
        #获取标签吓粉丝列表
        query_url ='https://api.weixin.qq.com/cgi-bin/user/tag/get?access_token=%s'% access_token
        params ={
            "tagid": tag_id, "next_openid": next_openid
        }
        response = requests.post(query_url,params)
        return json.loads(response.text,encoding='utf-8')
    注意:这个函数有问题。没有任何用户的标签,竟然返回了用户。需要在正式公众号下面测试。另外文档说是GET,实际需要post
  • 相关阅读:
    unity小记
    Animator 设置动画效果
    Animation(动画效果)
    蜜蜂游戏 小结
    unity 协同
    camera render texture 游戏里的监控视角
    Mybatis框架 第一天
    BOS项目 第12天(总结)
    BOS项目 第11天(activiti工作流第三天,流程实例管理、项目中的用户和角色同步到activiti的用户和组表、设计物流配送流程、启动物流配送流程、组任务操作(查询、拾取)、个人任务操作(查询、办理))
    BOS项目 第10天(activiti工作流第二天,流程变量、组任务、排他网关、spring整合activiti、项目中实现流程定义管理)
  • 原文地址:https://www.cnblogs.com/ahMay/p/12074744.html
Copyright © 2011-2022 走看看