收藏
回答

自定义菜单创建后公众号菜单乱码?

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 个回答

  • 疯狂的小辣椒
    疯狂的小辣椒
    2019-12-19

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

    2019-12-19
    有用
    回复
登录 后发表内容
问题标签