微信(公众号/小程序通用)通过code获取登录用户信息 Java后台实现

 

还有就是{"errcode":48001,"errmsg":"api unauthorized, hints: [ req_id: 1QoCla0699ns81 ]"}这种的

这种错误解决方案:  https://www.cnblogs.com/liaolongjun/p/6080240.html

https://www.cnblogs.com/sxmny/articles/4969119.html

一般情况下,所有的错误都是因为code要么用过了,要么没授权导致的

注意: 获取到的code只能用一次  

 

源码如下,时间赶得紧,写的比较烂

import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.teeqee.threeKingdomsGame.wx.miniapp.config.WxMaProperties;
import com.teeqee.threeKingdomsGame.wx.miniapp.pojo.SanGuoUser;
import com.teeqee.threeKingdomsGame.wx.miniapp.service.SanGuoUserService;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestCo
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值