微信小程序获取openid等参数报错errcode:48001 errmsg:'api unauthorized'


我的报这个错的时候,把url改成下面这个就可以了,

"https://api.weixin.qq.com/sns/jscode2session?appid=$appid&secret=$appsecret&js_code=$code&grant_type=authorization_code"


这个url有三种

1、$url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=$appid&secret=$appsecret&code=$code&grant_type=authorization_code";


2、$url = "https://api.weixin.qq.com/sns/oauth2/component/access_token?appid=$appid&secret=$appsecret&code=$code&grant_type=authorization_code";


3、$url = "https://api.weixin.qq.com/sns/jscode2session?appid=$appid&secret=$appsecret&js_code=$code&grant_type=authorization_code";


扫描二维码关注公众号,回复: 1585617 查看本文章


-----------------------------华丽分割线------------以上是我自己总结的--------以下是自己又查找的资料可以参考一下---------------------------

详细参考https://www.cnblogs.com/sxmny/articles/4969119.html


猜你喜欢

转载自blog.csdn.net/qq_38032300/article/details/79540998