#!/usr/bin/env python3
import requests

def get_token():
    appid = 'wxf83382ddf9fd606a'
    appsecret = 'd5c7f56c198684330ea642184012df8f'
    url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={appid}&secret={appsecret}'.format(appid=appid, appsecret=appsecret)
    r = requests.get(url)
    return r.json()['access_token']

def get_mini_prog_link(token):
    url = 'https://api.weixin.qq.com/wxa/generate_urllink?access_token=' + token
    r = requests.post(url, json={
        'path': 'pages/index/index',
    })
    print(r)
    print(r.json())
    return r.json()['url_link']

tk = get_token()
print('token:', tk)
link = get_mini_prog_link(tk)
print(link)
