本文使用Python調用微信小程序獲取access_token接口進行獲取請求憑據。爲了便於操做,這邊結合了Python自帶的GUI庫Tkinter。json
import requests import tkinter def GetAccessToken(): url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=你的APPID&secret=你的APPSECRET" res = requests.get(url) access_token = res.text print('已得到:'+access_token) # 寫入JSON文件,緩存到本地JSON文件 with open('access_token.json','w',encoding='utf-8') as f: f.write(access_token) # GUI操做界面 root = tkinter.Tk() root.geometry("500x300") root.title("TANKING") button = tkinter.Button(text="獲取access_token",command=GetAccessToken) button.pack() button.mainloop()
Author:TANKING
Date:2021-8-1
WeChat:sansure2016小程序