首页 > 编程知识 正文

小程序获取公众号openid,微信小程序获取用户openid

时间:2023-05-05 05:01:26 阅读:198710 作者:4963

无论是微信小程序还是微信公众号获取OPENID都需要先获取code

获取code

String url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + ticketWxConfig.getCustomAppId() + "&redirect_uri=" + URLEncoder.encode(redirect_uri, UTF_8) + "&response_type=code&scope=snsapi_base&state=STATE&connect_redirect=1#wechat_redirect";

微信公众号获取OPENID

String getAccessTokenUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?" + "appid=" + wxConfig.getCustomAppId() + "&secret=" + wxConfig.getCustomSecret() + "&code=" + code + "&grant_type=authorization_code";

微信小程序获取OPENID

String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxConfig.getAppletsAppId() + "&secret=" + wxConfig.getAppletsSecret() + "&js_code=" + code + "&grant_type=authorization_code";

微信官方文档

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。