msgSecCheck 在java后台返回41001,token有值?
发布于 6 年前 作者 jingyan 9286 次浏览 来自 官方Issues

package api;

import java.util.HashMap;

import java.util.Map;

import com.google.gson.JsonObject;

import com.google.gson.JsonParser;

import globle.UitlHttp;

import globle.Utilwx;

public class wxsscheck {

static wxsscheck s_wxsscheck;

public static wxsscheck getInstance() {

if (s_wxsscheck == null) {

s_wxsscheck = new wxsscheck();

}

return s_wxsscheck;

}

String mtookenString = “”;

long mtime = 0;

String check(String contextv) {

String url = “https://api.weixin.qq.com/wxa/msg_sec_check”;

Map<String, String> objmap = new HashMap<String, String>();

objmap.put(“content”, contextv);

objmap.put(“access_token”, mtookenString);

String reString = UitlHttp.dopost(url, “”, objmap);

return reString;

}

public String Checktxt(String contextv) {

if (System.currentTimeMillis() - mtime < 120 * 60 * 1000 && mtookenString.length() > 10) {

return check(contextv);

}

mtime = System.currentTimeMillis();

String url = “https://api.weixin.qq.com/cgi-bin/token”;

Map<String, String> objmap = new HashMap<String, String>();

objmap.put(“appid”, Utilwx.appid); 

objmap.put(“secret”, Utilwx.secret); 

objmap.put(“grant_type”, “client_credential”);

String access_token = UitlHttp.doGet(url, objmap);

if (access_token == null || access_token.length() < 1) {

return “no”;

} else if (access_token.contains(“errcode”)) {

return “no”;

}

JsonObject json = new JsonParser().parse(access_token).getAsJsonObject();

mtookenString = json.get(“access_token”).getAsString();

return check(contextv);

}

}


返回 {“errcode”:41001,“errmsg”:“access_token missing hint: [7qxEjA02498671!]”}

access_token,为什么返回41001

求解

3 回复

post请求地址需要携带access_token的值,https://api.weixin.qq.com/wxa/msg_sec_check?access_token=access_token的具体值

JavaScript案例如下:

{“errcode”:41001,“errmsg”:“access_token missing hint: [an2U808052281!]”}

access_token的值是:  27_vIsHtI0Ii1Io02WbjmHKqgldFTyE-c8ZBayZ-cGmn2p9WvU9otJkXRjWCDOCliHXzgIyITM2Vloj79ptQbrl8SFZIC-EHL_08E0mvLimZJg6I-2fYVXWwpCb9DYDGHgAIASVW

回到顶部