一、下载软件ngrok
下载地址:ngrok - secure introspectable tunnels to localhost
具体操作:Windows 下 配置 ngrok ngrok使用教程_冷秋月的专栏-CSDN博客_ngrok
二、修改本地hosts文件
这里显示的是window的路径,打开hosts文件,添加映射: 本地ip->测试域名
三、申请微信测试号
微信公众平台接口测试账号申请,输入生成的本地url地址
四、获取code
1.找到对应微信url地址(网页开发为例):
https://open.weixin.qq.com/connect/oauth2/authorize?appid=xxxxxx&redirect_uri=http%3A%2F%2Fxxx.xxx.cn&response_type=code&scope=snsapi_userinfo&state=STATE
2.微信开发者工具,选择公众号网页
3.输入对应并请求url地址后,可获取到code值