微信调试笔记

1.用户访问的网站为:

https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx0bf29b9a93ea6339&redirect_uri=http%3A%2F%2Febt.xust.edu.cn%2Fwx2%2Ftest&response_type=code&scope=snsapi_base&state=1#wechat_redirect

2服务器接受到微信服务器的参数

getRequestURI:/wx2/test

getQueryString:code=011N0fm41KCIDL1MO7o41H54m41N0fmA&state=1

3换取用户的openid

https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx0bf29b9a93ea6339&secret=替换为你的secret&code=011N0fm41KCIDL1MO7o41H54m41N0fmA&grant_type=authorization_code

服务器返回:

{"access_token":"9_RUgKqA8XHMzvgJoIlxJqRqI9ODVSWv0eJ2n4vLoe44z8qQSeCdXwt-iIZSchbUs45u-dETBzgkhCi69dcc5L-w","expires_in":7200,"refresh_token":"9_5aGK-oU4IIYynlkvVdmA-HJBBzhB61Ubq36Ur0cQoidiP2X7MtJnVGVU9wKemXr0LdmcWG9QpnUPFTrBWpq8nQ","openid":"oFzuz1IqdeovsWCs7IE6T1639p-o","scope":"snsapi_base"}

用户的openId拿到了。

猜你喜欢

转载自blog.csdn.net/tanxuefeng22/article/details/80091850