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')
公衆號創建自定義菜單
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.