公众号创建自定义菜单

def create_menu(request):
    '''
    公众号自定义创建菜单
    :param request:
    :return:
    '''
    # 获取token
    access_token = get_access_token()
    scheme = config["starkeyword_antd"]["scheme"]
    host = config["starkeyword_antd"]["host"]
    data = {
        "button": [
            {
                "name": "我的铲子",
                "sub_button": [
                    {
                        "type": "view",
                        "name": "购买铲子",
                        "url": "%s://%s/official/pay" % (scheme, host)
                    },
                    {
                        "type": "view",
                        "name": "铲子明细",
                        "url": "%s://%s/official/shovel" % (scheme, host)
                    },
                    {
                        "type": "click",
                        "name": "免费领铲子",
                        "key": "V1001_GET_SHOVEL"
                    },
                ]
            },
            {
                "name": "最新活动",
                "sub_button": [
                    {
                        "type": "view",
                        "name": "我的邀请",
                        "url": "%s://%s/official/invite" % (scheme, host)
                    },
                    {
                        "type": "view",
                        "name": "领小米音箱",
                        "url": "%s://%s/subject/20191111/home" % (scheme, host)
                    },

                ]
            },
            {
                "name": "我的余额",
                "sub_button": [
                    {
                        "type": "view",
                        "name": "财务记录",
                        "url": "%s://%s/official/finance" % (scheme, host)
                    },
                    {
                        "type": "view",
                        "name": "充值",
                        "url": "%s://%s/official/recharge" % (scheme, host)
                    },
                ]
            },

        ]
    }

    url = 'https://api.weixin.qq.com/cgi-bin/menu/create?access_token=' + access_token
    params = json.dumps(data, ensure_ascii=False)
    res = requests.post(url, data=params)
    print res.json()
    data = res.json()
    return HttpResponse(json.dumps(data), mimetype='application/javascript')

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

瓶瓶罐罐的

如果帮助到你了,请来点实际的

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值