自定义菜单创建后公众号菜单乱码?
发布于 5 年前 作者 baigang 10335 次浏览 来自 问答

java post 请求

public static String jsonPost(String url, JSONObject jsonObject){
    CloseableHttpClient httpclient = HttpClientBuilder.create().build();
    HttpPost post = new HttpPost(url);
    String response = null;
    try {
        StringEntity s = new StringEntity(jsonObject.toString());
        s.setContentEncoding("UTF-8");
        s.setContentType("application/json");//发送json数据需要设置contentType
        post.setEntity(s);
        HttpResponse res = httpclient.execute(post);
        if(res.getStatusLine().getStatusCode() == HttpStatus.SC_OK){
            String result = EntityUtils.toString(res.getEntity());// 返回json格式:
            response = JSONObject.toJSONString(result);
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return response;
}

1 回复

你好,麻烦具体描述下问题流程,提供下appid,完整的请求,最近一次操作时间(特别说明,5小时内才有机会快速定位)

回到顶部