刚刚刷新access_token,但请求https://api.weixin.qq.com/cgi-bin/user/info报40001。其中:
----------获取access_token接口方法-----------------------------------------------------------
public final static String ACCESS_TOKEN_URL = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=CORPID&corpsecret=CORPSECRET";
public static JSONObject getAccessTokenInfo(String appid, String appsecret, String wechattype) {
String requestUrl = "";
JSONObject accesstokenJson = new JSONObject();
//企业号
requestUrl = WeiXinUtil.ACCESS_TOKEN_URL;
requestUrl = requestUrl.replace("CORPID", appid).replace("CORPSECRET", appsecret);
accesstokenJson = HttpUtil.httpRequestwx(requestUrl, "GET", null);
return accesstokenJson;
}
-----------转unionid方法-------------------------------------------------------------------------
public static void main(String[] args) {
String token = "token";
String userinfostr = HttpUtil.sendGet("https://api.weixin.qq.com/cgi-bin/user/info", "access_token="+token+"&openid="+"openid"+"&lang=zh_CN", "UTF-8");
JSONObject userinfo = JSONObject.parseObject(userinfostr);
System.out.println(userinfo);
}
----------------返回-----------------------------------
errcode -> {Integer@1525} 40001
errmsg -> invalid credential, access_token is invalid or not latest, could get access_token by getStableAccessToken, more details at https://mmbizurl.cn/s/JtxxFh33r rid: 65f01511-144c0b9c-005c25a6
你好,日志查看,token错误
request: access_token=Oz0LNVB2CpqiEW7a6g1A6bZHBm65Zw-uhW2NybVTR9NucCsBvuWLTESvX_hfINkPB45EYfoolnqgbhE11-T69r9kT_zuG_NzR_NYR0OWF5DBlB4M2gGbJwGLSxoKGwEInH55Q8KK7vSLiT7dDEN4W7RZYQqUSQgBcl92DvWcozm13rgsFB7f1adqPFGt4jFYdVeCtGB6K9IvlDkBN1PKOaeiI_wQXUV4K-IF7jlP3XA&openid=oGqZTs8KHVIEz6GqVi2yI4YQnVT8&lang=zh_CN
企业微信token 和普通公众号token 并不是互通的;想要获取 用户openid,使用 userId转换openid接口即可
企业微信的 token?你应该调用这个https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Get_access_token.html