调用auth.code2Session返回值报错,怎么解决?
发布于 5 年前 作者 taoxiulan 12394 次浏览 来自 官方Issues

{“errcode”:40013,“errmsg”:“invalid appid, hints: [ req_id: JGHEu.wgE-ctEZVA ]”}

public  String do_get(String JSCODE) throws ClientProtocolException, IOException {
        String body = "{}";
        String APPID = "wxbea50118b27deed2";
        String SECRET = "916e340c613a39a413076a03d5379692";
//        String JSCODE1 = "021Ktl4S1ognG510zT2S1f7w4S1Ktl4Q";
        DefaultHttpClient httpclient = new DefaultHttpClient();
        try {
            HttpGet httpget = new HttpGet("https://api.weixin.qq.com/sns/jscode2session?appid="+APPID+"+&secret="+SECRET+"&js_code="+JSCODE+"&grant_type=authorization_code");
            SSLSocketFactory.getSocketFactory().setHostnameVerifier(new AllowAllHostnameVerifier());
            HttpResponse response = httpclient.execute(httpget);
            HttpEntity entity = response.getEntity();
            body = EntityUtils.toString(entity);
            System.out.println(body);
        } finally {
            httpclient.getConnectionManager().shutdown();
        }
        return body;
    }
1 回复

不好意思,是我自己拼接错误了,汗颜

回到顶部