zoukankan      html  css  js  c++  java
  • HttpClient request payload post请求

    https://blog.csdn.net/hhooong/article/details/52750647

    //获取订单详情需要的传递的参数
    String paramsOrder = "{"hotelRange": "1", "lstChannelSourceType": [1, 4], "languageTypeEnum": "LANG_ZH"}";
    //发包形式获取订单详情
    String orderDetail = post(httclient, "https://www.plateno.com/api/order/queryOrderList", paramsOrder, buffer.toString().replaceAll("path=/,", "").replaceAll("path=/", "").replace("; ;", ";"));

    封装post

    /**
         *参数为PayLoad形式的参数请求 
         */
        public String post(HttpClient httpClient, String url, String str, String cookie) throws ParseException, IOException{
            PostMethod post = new PostMethod(url);
            post.setRequestHeader("Accept", "application/json, text/plain, */*");
            post.setRequestHeader("Accept-Encoding", "gzip, deflate, br");
            post.setRequestHeader("Accept-Language", "zh-CN,zh;q=0.9");
            post.setRequestHeader("Connection", "keep-alive");
            post.setRequestHeader("Host", "www.plateno.com");
            post.setRequestHeader("Cookie", cookie);
            post.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
            post.setRequestHeader("Origin", "https://www.plateno.com");
            post.setRequestHeader("Referer", "https://www.plateno.com/Club/MemberInfo/");
            post.setRequestHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.75 Safari/537.36");
            RequestEntity entity = new StringRequestEntity(str, "application/json;charset=UTF-8", "utf-8");
            post.setRequestEntity(entity);
            httpClient.executeMethod(post);
            String result = post.getResponseBodyAsString();
            return result;
        }
  • 相关阅读:
    vim 命令
    navicat 破解
    vim 使用技巧记录
    Ubuntu 16.04 安装ftp服务器
    mockito测试入门学习
    Java的getClass()函数
    JQuery中Ajax的操作
    JS中获取元素使用getElementByID()、getElementsByName()、getElementsByTagName()的用法和区别
    Tomcat下ajax请求路径总结
    javascript:void()的理解
  • 原文地址:https://www.cnblogs.com/person008/p/10980824.html
Copyright © 2011-2022 走看看