微信开发
接口配置信息修改
例如:编写一个公网接口 http://1b51z57431.51mypc.cn/tokenAuth 点击修改接口配置信息的时候,腾讯会给http://1b51z57431.51mypc.cn/tokenAuth 发送一个get请求,包含参数echostr,此时需要将echostr原路返回,就能够 修改接口配置信成功
@GetMapping(value = "/tokenAuth") public String tokenAuth(HttpServletRequest httpServletRequest){ Map<String, String> param = Request2Map.toMap(httpServletRequest); return param.get("echostr"); }
修改JS安全域名
设置网页帐号-网页授权获取用户基本信息
- 将1b51z57431.51mypc.cn填入即可
获取授权code
- 拼装并请求:https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx23007a86f39ac469&redirect_uri=http%3A%2F%2F1b51z57431.51mypc.cn%2Fauthorization&response_type=code&scope=snsapi_base&state=123#wechat_redirect
- H5平台demo【https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx0d453bb3d089f6f9&redirect_uri=http%3A%2F%2Ffanxx4.natapp1.cc%2Fww_h5_dx%2F%23%2Fard%3Ftoken%3D12345&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect】
- 微信会回调到:http://1b51z57431.51mypc.cn/authorization?code=001NOmD91cWL6N1S1lF911BoD91NOmDO&state=123 回调会带入授权code
- 将获取到的授权code生成授权链接
- 静默授权: https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx23007a86f39ac469&redirect_uri=http%3A%2F%2F1b51z57431.51mypc.cn%2Fauthorization&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect 会得到openid,access_token等参数
- 非静默授权-用户确认授权:https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx23007a86f39ac469&redirect_uri=http%3A%2F%2F1b51z57431.51mypc.cn%2Fauthorization_userinfo&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect 会得到头像昵称等数据
公众号菜单栏配置
打开https://mp.weixin.qq.com/debug/cgi-bin/apiinfo
- 接口类型选择-基础支持
- 设置appid和appsecret获取access_token
选择自定义菜单-自定义菜单创建接口/menue/create填入access_token并填入body为下:
{ "button":[ { "type":"click", "name":"测试", "key":"V1001_TODAY_MUSIC" }, { "name":"营销服务", "sub_button":[ { "type":"view", "name":"百度", "url":"http://www.baidu.com/" },{ "type":"view", "name":"110元活动", "url":"http://xupeng.nat300.top/ww_h5/#/invite/leading?registerChannel=3AnOA2Y2136&activityCode=AC10003&moduleCode=M1&platform=ssz&userData=" },{ "type":"view", "name":"openId-头像测试", "url":"http://xupeng.nat300.top/ww_h5/#/" } ] }] }
即可创建菜单栏