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')
公众号创建自定义菜单
最新推荐文章于 2024-06-03 15:42:37 发布