微信——获取用户基本信息及openid 、access_token、code


获取用户信息,需要获取 access_tokenopenid

然后调用接口https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN

 

access_token:公众号的全局唯一票据,

获取access_token,需要调用https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET

参数 是否必须 说明
grant_type 获取access_token填写client_credential
appid 第三方用户唯一凭证
secret 第三方用户唯一凭证密钥,即appsecret

 

 

 

 

 

openid:普通用户的标识,对当前公众号唯一

获取openid需要先获取code,

获取code需要调用接口

https://open.weixin.qq.com/connect/oauth2/authorize?appid=appid&redirect_uri=现在访问的方法的url&response_type=code&scope=snsapi_userinfo&state=STATE

获取code后,

再调用接口https://api.weixin.qq.com/sns/oauth2/access_token?appid=appid&secret=secret&code=code&grant_type=authorization_code以获取openid


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM