Java 类org.apache.http.message.BasicNameValuePair 实例源码

项目:publicProject    文件:HttpClientStack.java   
@SuppressWarnings("unused")
private static List<NameValuePair> getPostParameterPairs(Map<String, String> postParams) {
    List<NameValuePair> result = new ArrayList<NameValuePair>(postParams.size());
    for (String key : postParams.keySet()) {
        result.add(new BasicNameValuePair(key, postParams.get(key)));
    }
    return result;
}
项目:letv    文件:PlayRecordApi.java   
@Deprecated
public String s_sendMobile(int updataId, String mobile, String ver, String Cookid) {
    String requestUrl;
    if (PreferencesManager.getInstance().isTestApi() && LetvConfig.isForTest()) {
        requestUrl = "http://test2.m.letv.com/android/dynamic.php";
    } else {
        requestUrl = "http://dynamic.user.app.m.letv.com/android/dynamic.php";
    }
    String str = MD5.toMd5("action=reg&mobile=" + mobile + "&pcode=" + LetvConfig.getPcode() + "&plat=mobile_tv" + "&version=" + LetvUtils.getClientVersionName() + "&poi345");
    List<BasicNameValuePair> list = new ArrayList();
    list.add(new BasicNameValuePair("mod", MODIFYPWD_PARAMETERS.MOD_VALUE));
    list.add(new BasicNameValuePair("ctl", "clientSendMsg"));
    list.add(new BasicNameValuePair(SocialConstants.PARAM_ACT, "index"));
    list.add(new BasicNameValuePair("mobile", mobile));
    list.add(new BasicNameValuePair(MODIFYPWD_PARAMETERS.PLAT_KEY, "mobile_tv"));
    list.add(new BasicNameValuePair(MODIFYPWD_PARAMETERS.APISIGN_KEY, str));
    list.add(new BasicNameValuePair("action", "reg"));
    list.add(new BasicNameValuePair("captchaValue", ver));
    list.add(new BasicNameValuePair("captchaId", Cookid));
    list.add(new BasicNameValuePair("pcode", LetvConfig.getPcode()));
    list.add(new BasicNameValuePair("version", LetvUtils.getClientVersionName()));
    Log.e("ZSM", "s_sendMobile url == " + ParameterBuilder.getQueryUrl(list, requestUrl));
    return ParameterBuilder.getQueryUrl(list, requestUrl);
}
项目:Higher-Cloud-Computing-Project    文件:ServerUtil.java   
public static String register(String email_addr, String nick_name, String pwd) throws Exception {

        HttpClient task_post = new DefaultHttpClient();
        HttpPost post = new HttpPost(url + "/Register");
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("email_addr", email_addr));
        params.add(new BasicNameValuePair("nick_name", nick_name));
        params.add(new BasicNameValuePair("pwd", pwd));
        post.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
        HttpResponse response = task_post.execute(post);
        if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
            String result = null;
            HttpEntity httpEntity = response.getEntity();
            if (httpEntity != null) {
                result = EntityUtils.toString(httpEntity);
            }
            JSONObject jsonObject = new JSONObject(result);
            int register_status = jsonObject.getInt("register_status");
            int user_id = jsonObject.getInt("user_id");
            if (register_status == 1)
                return "SUCCESS,your user_id is " + String.valueOf(user_id);
            else
                return "FAIL";
        }
        return "401 UNAUTHORIZED";
    }
项目:letv    文件:UserCenterApi.java   
public String getChatRecords(String roomId, boolean server, String tm, int mode) {
    String keyb = roomId + "," + tm + "," + LetvConstant.CHAT_KEY;
    ArrayList<BasicNameValuePair> params = new ArrayList();
    params.add(new BasicNameValuePair("luamod", "main"));
    params.add(new BasicNameValuePair("mod", HOME_RECOMMEND_PARAMETERS.MOD_VALUE));
    params.add(new BasicNameValuePair("ctl", "chatGethistory"));
    params.add(new BasicNameValuePair(SocialConstants.PARAM_ACT, "index"));
    params.add(new BasicNameValuePair("roomId", roomId));
    params.add(new BasicNameValuePair("server", String.valueOf(server)));
    params.add(new BasicNameValuePair("tm", tm));
    params.add(new BasicNameValuePair("key", MD5.toMd5(keyb)));
    params.add(new BasicNameValuePair("pcode", LetvConfig.getPcode()));
    if (mode == 0) {
        params.add(new BasicNameValuePair("version", LetvUtils.getClientVersionName()));
    } else {
        params.add(new BasicNameValuePair("version", "6.0"));
    }
    LogInfo.log("clf", "获取历史聊天记录requestChatRecords..url=" + ParameterBuilder.getQueryUrl(params, getDynamicUrl()));
    return ParameterBuilder.getQueryUrl(params, getDynamicUrl());
}
项目:elasticjob-stock-push    文件:HttpUtils.java   
/**
 * post form
 *
 * @param host
 * @param path
 * @param method
 * @param headers
 * @param querys
 * @param bodys
 * @return
 * @throws Exception
 */
public static HttpResponse doPost(String host, String path, String method,
                                  Map<String, String> headers,
                                  Map<String, String> querys,
                                  Map<String, String> bodys)
        throws Exception {
    HttpClient httpClient = wrapClient(host);

    HttpPost request = new HttpPost(buildUrl(host, path, querys));
    for (Map.Entry<String, String> e : headers.entrySet()) {
        request.addHeader(e.getKey(), e.getValue());
    }

    if (bodys != null) {
        List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();

        for (String key : bodys.keySet()) {
            nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key)));
        }
        UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");
        formEntity.setContentType("application/x-www-form-urlencoded");

        request.setEntity(formEntity);
    }

    return httpClient.execute(request);
}
项目:mxisd    文件:SessionMananger.java   
private void submitRemote(ThreePidSession session, String token) {
    UrlEncodedFormEntity entity = new UrlEncodedFormEntity(
            Arrays.asList(
                    new BasicNameValuePair("sid", session.getRemoteId()),
                    new BasicNameValuePair("client_secret", session.getRemoteSecret()),
                    new BasicNameValuePair("token", token)
            ), StandardCharsets.UTF_8);
    HttpPost submitReq = new HttpPost(session.getRemoteServer() + "/_matrix/identity/api/v1/submitToken");
    submitReq.setEntity(entity);

    try (CloseableHttpResponse response = client.execute(submitReq)) {
        JsonObject o = new GsonParser().parse(response.getEntity().getContent());
        if (!o.has("success") || !o.get("success").getAsBoolean()) {
            String errcode = o.get("errcode").getAsString();
            throw new RemoteIdentityServerException(errcode + ": " + o.get("error").getAsString());
        }

        log.info("Successfully submitted validation token for {} to {}", session.getThreePid(), session.getRemoteServer());
    } catch (IOException e) {
        throw new RemoteIdentityServerException(e.getMessage());
    }
}
项目:letv    文件:PlayRecordApi.java   
public static String requestPraiseInfo(int updataId) {
    String baseUrl = getUserDynamicUrl();
    String uid = LetvUtils.getUID();
    String userName = LetvUtils.getLoginUserName();
    String deviceId = LetvUtils.generateDeviceId(BaseApplication.getInstance());
    StringBuilder md5Sb = new StringBuilder();
    md5Sb.append("uid=" + uid + "&");
    md5Sb.append("username=" + userName + "&");
    md5Sb.append("devid=" + deviceId + "&");
    md5Sb.append("pcode=" + LetvConfig.getPcode() + "&");
    md5Sb.append("version=" + LetvUtils.getClientVersionName() + "&");
    md5Sb.append("letvpraise2014");
    String md5Sign = MD5.toMd5(md5Sb.toString());
    ArrayList<BasicNameValuePair> params = new ArrayList();
    params.add(new BasicNameValuePair("mod", "passport"));
    params.add(new BasicNameValuePair("ctl", "index"));
    params.add(new BasicNameValuePair(SocialConstants.PARAM_ACT, "praiseactivity"));
    params.add(new BasicNameValuePair("uid", uid));
    params.add(new BasicNameValuePair("username", userName));
    params.add(new BasicNameValuePair(HOME_RECOMMEND_PARAMETERS.DEVICEID_KEY, deviceId));
    params.add(new BasicNameValuePair("pcode", LetvConfig.getPcode()));
    params.add(new BasicNameValuePair("version", LetvUtils.getClientVersionName()));
    params.add(new BasicNameValuePair(TradeInfo.SIGN, md5Sign));
    return ParameterBuilder.getQueryUrl(params, baseUrl);
}
项目:letv    文件:PlayRecordApi.java   
public String deletePlayTraces(int updataId, String pid, String vid, String uid, String idstr, String flush, String backdata, String sso_tk) {
    String baseUrl = UrlConstdata.getDynamicUrl();
    List<BasicNameValuePair> list = new ArrayList();
    list.add(new BasicNameValuePair("mod", "minfo"));
    list.add(new BasicNameValuePair("ctl", "cloud"));
    list.add(new BasicNameValuePair(SocialConstants.PARAM_ACT, "del"));
    list.add(new BasicNameValuePair("pid", pid));
    list.add(new BasicNameValuePair("vid", vid));
    list.add(new BasicNameValuePair("uid", uid));
    list.add(new BasicNameValuePair("idstr", idstr));
    list.add(new BasicNameValuePair("flush", flush));
    list.add(new BasicNameValuePair("backdata", backdata));
    list.add(new BasicNameValuePair("sso_tk", sso_tk));
    list.add(new BasicNameValuePair("pcode", LetvHttpApiConfig.PCODE));
    list.add(new BasicNameValuePair("version", LetvHttpApiConfig.VERSION));
    return ParameterBuilder.getQueryUrl(list, baseUrl);
}
项目:Equella    文件:MyResourcesApiTest.java   
private JsonNode doMyResourcesSearch(String query, String subsearch, Map<?, ?> otherParams, String token)
    throws Exception
{
    List<NameValuePair> params = Lists.newArrayList();
    if( query != null )
    {
        params.add(new BasicNameValuePair("q", query));
    }
    for( Entry<?, ?> entry : otherParams.entrySet() )
    {
        params.add(new BasicNameValuePair(entry.getKey().toString(), entry.getValue().toString()));
    }
    // params.add(new BasicNameValuePair("token",
    // TokenSecurity.createSecureToken(username, "token", "token", null)));
    String paramString = URLEncodedUtils.format(params, "UTF-8");
    HttpGet get = new HttpGet(context.getBaseUrl() + "api/search/myresources/" + subsearch + "?" + paramString);
    HttpResponse response = execute(get, false, token);
    return mapper.readTree(response.getEntity().getContent());
}
项目:Higher-Cloud-Computing-Project    文件:ServerUtil.java   
/**
 * send current ip to server
 */
private String ipSend() throws Exception {
    HttpClient ip_send = new DefaultHttpClient();
    HttpPost post = new HttpPost(url + "/UploadIP");
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("machine_id", String.valueOf(machine_id)));
    params.add(new BasicNameValuePair("ip", ip));
    post.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
    HttpResponse httpResponse = ip_send.execute(post);
    if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
        String result = null;
        HttpEntity httpEntity = httpResponse.getEntity();
        if (httpEntity != null) {
            result = EntityUtils.toString(httpEntity);
        }
        JSONObject jsonObject = new JSONObject(result);
        int ip_save = jsonObject.getInt("ip_save");
        if (ip_save == 1) {
            return "SUCCESS";
        } else return "FAIL";
    }
    return "401 UNAUTHORIZED";
}
项目:letv    文件:PlayRecordApi.java   
public String loginWeixin(int updataId, String accessToken, String openId, String plat, String equipType, String equipID, String softID, String pcode, String version) {
    String baseUrl = UrlConstdata.getDynamicUrl();
    List<BasicNameValuePair> list = new ArrayList();
    list.add(new BasicNameValuePair("luamod", "main"));
    list.add(new BasicNameValuePair("mod", HOME_RECOMMEND_PARAMETERS.MOD_VALUE));
    list.add(new BasicNameValuePair("ctl", "appssoweixin"));
    list.add(new BasicNameValuePair(SocialConstants.PARAM_ACT, "index"));
    list.add(new BasicNameValuePair("access_token", accessToken));
    list.add(new BasicNameValuePair("openid", openId));
    list.add(new BasicNameValuePair(MODIFYPWD_PARAMETERS.PLAT_KEY, plat));
    list.add(new BasicNameValuePair("equipID", equipID));
    list.add(new BasicNameValuePair("softID", softID));
    list.add(new BasicNameValuePair("pcode", pcode));
    list.add(new BasicNameValuePair("version", version));
    list.add(new BasicNameValuePair("imei", LetvUtils.getIMEI()));
    list.add(new BasicNameValuePair("mac", LetvUtils.getMacAddressForLogin()));
    return ParameterBuilder.getQueryUrl(list, baseUrl);
}
项目:letv    文件:LetvUrlMaker.java   
public static String getAlbumByTimeUrl(String year, String month, String id, String videoType) {
    String head = getStaticHead() + "/mod/mob/ctl/videolistbydate/act/detail";
    String end = LetvHttpApiConfig.getStaticEnd();
    ArrayList<BasicNameValuePair> params = new ArrayList();
    params.add(new BasicNameValuePair("version", LetvUtils.getClientVersionName()));
    params.add(new BasicNameValuePair("pcode", LetvUtils.getPcode()));
    if (!TextUtils.isEmpty(year)) {
        params.add(new BasicNameValuePair("year", year));
    }
    if (!TextUtils.isEmpty(month)) {
        params.add(new BasicNameValuePair("month", month));
    }
    params.add(new BasicNameValuePair("id", id));
    if (!TextUtils.isEmpty(videoType)) {
        params.add(new BasicNameValuePair(PlayConstant.VIDEO_TYPE, videoType));
    }
    return ParameterBuilder.getPathUrl(params, head, end);
}
项目:Higher-Cloud-Computing-Project    文件:ServerUtil.java   
public static String resetPwd(int user_id, String pwd) throws Exception {

        HttpClient task_post = new DefaultHttpClient();
        HttpPost post = new HttpPost(url + "/ResetPwd");
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("user_id", String.valueOf(user_id)));
        params.add(new BasicNameValuePair("pwd", pwd));
        post.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
        HttpResponse response = task_post.execute(post);
        if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
            String result = null;
            HttpEntity httpEntity = response.getEntity();
            if (httpEntity != null) {
                result = EntityUtils.toString(httpEntity);
            }
            JSONObject jsonObject = new JSONObject(result);
            int pwd_reset = jsonObject.getInt("pwd_reset");
            if (pwd_reset == 1)
                return "SUCCESS";
            else
                return "FAIL";
        }
        return "401 UNAUTHORIZED";
    }
项目:boohee_v5.6    文件:HTTPClient.java   
public String PostConnect(String httpUrl, String str) {
    String resultData = "";
    HttpPost httpPost = new HttpPost(httpUrl);
    List<NameValuePair> params = new ArrayList();
    params.add(new BasicNameValuePair("data", str));
    try {
        httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
        HttpResponse httpResponse = new DefaultHttpClient().execute(httpPost);
        if (httpResponse.getStatusLine().getStatusCode() == 200) {
            resultData = EntityUtils.toString(httpResponse.getEntity());
        }
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (UnsupportedEncodingException e2) {
        e2.printStackTrace();
    } catch (IOException e3) {
        e3.printStackTrace();
    }
    return resultData;
}
项目:letv    文件:LetvUrlMaker.java   
public static String getAlbumByTimeUrl(String year, String month, String id, String videoType) {
    String head = getStaticHead() + "/mod/mob/ctl/videolistbydate/act/detail";
    String end = LetvHttpApiConfig.getStaticEnd();
    ArrayList<BasicNameValuePair> params = new ArrayList();
    params.add(new BasicNameValuePair("version", LetvUtils.getClientVersionName()));
    params.add(new BasicNameValuePair("pcode", LetvUtils.getPcode()));
    if (!TextUtils.isEmpty(year)) {
        params.add(new BasicNameValuePair("year", year));
    }
    if (!TextUtils.isEmpty(month)) {
        params.add(new BasicNameValuePair("month", month));
    }
    params.add(new BasicNameValuePair("id", id));
    if (!TextUtils.isEmpty(videoType)) {
        params.add(new BasicNameValuePair(PlayConstant.VIDEO_TYPE, videoType));
    }
    return ParameterBuilder.getPathUrl(params, head, end);
}
项目:rest-client    文件:FormEncodedBody.java   
private List<NameValuePair> getList(Map<String, List<Object>> parameters) {
    List<NameValuePair> result = new ArrayList<NameValuePair>();
    if (parameters != null) {
        TreeMap<String, List<Object>> sortedParameters = new TreeMap<String, List<Object>>(parameters);
        for (Map.Entry<String, List<Object>> entry : sortedParameters.entrySet()) {
            List<Object> entryValue = entry.getValue();
            if (entryValue != null) {
                for (Object cur : entryValue) {
                    if (cur != null) {
                        result.add(new BasicNameValuePair(entry.getKey(), cur.toString()));
                    }
                }
            }
        }
    }
    return result;
}
项目:Huochexing12306    文件:A6OrderAty.java   
private List<OrderDBInfo> queryMyOrderNoComplete(BookingInfo bInfo) {
    String url = "https://kyfw.12306.cn/otn/queryOrder/queryMyOrderNoComplete";
    List<NameValuePair> lstParams = new ArrayList<NameValuePair>();
    lstParams.add(new BasicNameValuePair("_json_att", ""));
    try {
        A6Info a6Json = A6Util
                .post(bInfo,
                        A6Util.makeRefererColl("https://kyfw.12306.cn/otn/queryOrder/initNoComplete"),
                        url, lstParams);
        if ("".equals(a6Json.getData())) {
            return (new ArrayList<OrderDBInfo>());
        } else {
            int index1 = a6Json.getData().indexOf("[");
            int index2 = a6Json.getData().lastIndexOf("]") + 1;
            String strOrderDBList = a6Json.getData().substring(index1,
                    index2);
            List<OrderDBInfo> lstODBInfos = A6Util.getGson().fromJson(
                    strOrderDBList, new TypeToken<List<OrderDBInfo>>() {
                    }.getType());
            return lstODBInfos;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
项目:Higher-Cloud-Computing-Project    文件:ServerUtil.java   
public static String active(int user_id, String verification_code) throws Exception {
    HttpClient task_post = new DefaultHttpClient();
    HttpPost post = new HttpPost(url + "/Active");
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("user_id", String.valueOf(user_id)));
    params.add(new BasicNameValuePair("verification_code", verification_code));
    post.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
    HttpResponse response = task_post.execute(post);
    if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
        String result = null;
        HttpEntity httpEntity = response.getEntity();
        if (httpEntity != null) {
            result = EntityUtils.toString(httpEntity);
        }
        JSONObject jsonObject = new JSONObject(result);
        int email_verification = jsonObject.getInt("email_verification");
        if (email_verification == 1)
            return "SUCCESS";
        else
            return "FAIL";
    }
    return "401 UNAUTHORIZED";
}
项目:android-advanced-light    文件:MainActivity.java   
private void useHttpClientPost(String url) {
    HttpPost mHttpPost = new HttpPost(url);
    mHttpPost.addHeader("Connection", "Keep-Alive");
    try {
        HttpClient mHttpClient = createHttpClient();
        List<NameValuePair> postParams = new ArrayList<>();
        //要传递的参数
        postParams.add(new BasicNameValuePair("ip", "59.108.54.37"));
        mHttpPost.setEntity(new UrlEncodedFormEntity(postParams));
        HttpResponse mHttpResponse = mHttpClient.execute(mHttpPost);
        HttpEntity mHttpEntity = mHttpResponse.getEntity();
        int code = mHttpResponse.getStatusLine().getStatusCode();
        if (null != mHttpEntity) {
            InputStream mInputStream = mHttpEntity.getContent();
            String respose = converStreamToString(mInputStream);
            Log.d(TAG, "请求状态码:" + code + "\n请求结果:\n" + respose);
            mInputStream.close();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
项目:httpclient    文件:RestClient.java   
@SuppressWarnings("unchecked")
private HttpEntity createDataEntity(Object data) {
    try {
        if (data instanceof Map) {
            List<NameValuePair> params = new ArrayList<NameValuePair>(0);
            for (Entry<String, Object> entry : ((Map<String, Object>) data).entrySet()) {
                params.add(new BasicNameValuePair(entry.getKey(), entry.getValue().toString()));
            }
            return new UrlEncodedFormEntity(params, "UTF-8");
        } else {
            return new StringEntity(data.toString(), "UTF-8");
        }
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException("Unsupported encoding noticed. Error message: " + e.getMessage());
    }
}
项目:letv    文件:PlayRecordApi.java   
public String loginSina(int updataId, String accessToken, String openId, String plat, String equipType, String equipID, String softID, String pcode, String version) {
    String baseUrl = UrlConstdata.getDynamicUrl();
    List<BasicNameValuePair> list = new ArrayList();
    list.add(new BasicNameValuePair("luamod", "main"));
    list.add(new BasicNameValuePair("mod", HOME_RECOMMEND_PARAMETERS.MOD_VALUE));
    list.add(new BasicNameValuePair("ctl", "appssosina"));
    list.add(new BasicNameValuePair(SocialConstants.PARAM_ACT, "index"));
    list.add(new BasicNameValuePair("access_token", accessToken));
    list.add(new BasicNameValuePair("uid", openId));
    list.add(new BasicNameValuePair(MODIFYPWD_PARAMETERS.PLAT_KEY, plat));
    list.add(new BasicNameValuePair("equipType", equipType));
    list.add(new BasicNameValuePair("equipID", equipID));
    list.add(new BasicNameValuePair("pcode", pcode));
    list.add(new BasicNameValuePair("softID", softID));
    list.add(new BasicNameValuePair("version", version));
    list.add(new BasicNameValuePair("imei", LetvUtils.getIMEI()));
    list.add(new BasicNameValuePair("mac", LetvUtils.getMacAddressForLogin()));
    return ParameterBuilder.getQueryUrl(list, baseUrl);
}
项目:smn-sdk-java    文件:ListSmsCallbackEventRequest.java   
/**
 * obtain the get request param
 *
 * @return the param string
 */
private String getRequestParamString() {
    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    if (!StringUtils.isBlank(eventType)) {
        nameValuePairs.add(new BasicNameValuePair(SmnConstants.EVENT_TYPE, eventType));
    }

    String param = "";
    if (!nameValuePairs.isEmpty()) {
        try {
            param = EntityUtils.toString(new UrlEncodedFormEntity(nameValuePairs, Charset.forName("UTF-8")));
        } catch (IOException e) {
            throw new RuntimeException("get request param error");
        }
    }
    return param;
}
项目:elasticjob-oray-client    文件:HttpUtils.java   
/**
 * post form
 *
 * @param host
 * @param path
 * @param method
 * @param headers
 * @param querys
 * @param bodys
 * @return
 * @throws Exception
 */
public static HttpResponse doPost(String host, String path, String method,
                                  Map<String, String> headers,
                                  Map<String, String> querys,
                                  Map<String, String> bodys)
        throws Exception {
    HttpClient httpClient = wrapClient(host);

    HttpPost request = new HttpPost(buildUrl(host, path, querys));
    for (Map.Entry<String, String> e : headers.entrySet()) {
        request.addHeader(e.getKey(), e.getValue());
    }

    if (bodys != null) {
        List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();

        for (String key : bodys.keySet()) {
            nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key)));
        }
        UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");
        formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
        request.setEntity(formEntity);
    }

    return httpClient.execute(request);
}
项目:letv    文件:PlayRecordApi.java   
public String requestTicketUrl(int updataId, String userId, String days) {
    String baseUrl;
    if (PreferencesManager.getInstance().isTestApi() && LetvConfig.isForTest()) {
        baseUrl = "http://t.api.mob.app.letv.com/yuanxian/myTickets?";
    } else {
        baseUrl = "http://api.mob.app.letv.com/yuanxian/myTickets?";
    }
    List<BasicNameValuePair> list = new ArrayList();
    list.add(new BasicNameValuePair("uid", userId));
    list.add(new BasicNameValuePair("days", days));
    list.add(new BasicNameValuePair("mac", LetvUtils.getMacAddress()));
    list.add(new BasicNameValuePair("pcode", LetvConfig.getPcode()));
    list.add(new BasicNameValuePair("version", LetvUtils.getClientVersionName()));
    Log.e("ZSM", "requestTicketUrl url == " + ParameterBuilder.getQueryUrl(list, baseUrl));
    return ParameterBuilder.getQueryUrl(list, baseUrl);
}
项目:FaceDistinguish    文件:HttpUtil.java   
/**
 * 构建FormEntity
 * 
 * @param formParam
 * @return
 * @throws UnsupportedEncodingException
 */
private static UrlEncodedFormEntity buildFormEntity(Map<String, String> formParam)
        throws UnsupportedEncodingException {
    if (formParam != null) {
        List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();

        for (String key : formParam.keySet()) {
            nameValuePairList.add(new BasicNameValuePair(key, formParam.get(key)));
        }
        UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, Constants.ENCODING);
        formEntity.setContentType(ContentType.CONTENT_TYPE_FORM);
        return formEntity;
    }

    return null;
}
项目:android-project-gallery    文件:RequestParams.java   
protected List<BasicNameValuePair> getParamsList() {
    List<BasicNameValuePair> lparams = new LinkedList<BasicNameValuePair>();

    for (ConcurrentHashMap.Entry<String, String> entry : urlParams.entrySet()) {
        lparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
    }

    lparams.addAll(getParamsList(null, urlParamsWithObjects));

    return lparams;
}
项目:lams    文件:URIBuilder.java   
/**
 * Sets parameter of URI query overriding existing value if set. The parameter name and value
 * are expected to be unescaped and may contain non ASCII characters.
 */
public URIBuilder setParameter(final String param, final String value) {
    if (this.queryParams == null) {
        this.queryParams = new ArrayList<NameValuePair>();
    }
    if (!this.queryParams.isEmpty()) {
        for (Iterator<NameValuePair> it = this.queryParams.iterator(); it.hasNext(); ) {
            NameValuePair nvp = it.next();
            if (nvp.getName().equals(param)) {
                it.remove();
            }
        }
    }
    this.queryParams.add(new BasicNameValuePair(param, value));
    this.encodedQuery = null;
    this.encodedSchemeSpecificPart = null;
    return this;
}
项目:Higher-Cloud-Computing-Project    文件:ServerUtil.java   
public String update_online_time(int machine_id, int user_id, int delta) throws Exception {

        HttpClient task_post = new DefaultHttpClient();
        HttpPost post = new HttpPost(url + "/update_online_time");
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("machine_id", String.valueOf(machine_id)));
        params.add(new BasicNameValuePair("user_id", String.valueOf(user_id)));
        params.add(new BasicNameValuePair("delta", String.valueOf(delta)));
        post.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
        HttpResponse response = task_post.execute(post);
        if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
//        权限通过
            return "AUTHORIZED";
        }
        return "401 UNAUTHORIZED";
    }
项目:momo-2    文件:WebServer.java   
/**
 * Perform an Oauth2 callback to the Discord servers with the token given by the user's approval
 * @param token Token from user
 * @param res Passed on response
 * @throws ClientProtocolException Error in HTTP protocol
 * @throws IOException Encoding exception or error in protocol
 * @throws NoAPIKeyException No API keys set
 */
static void oauth(String token, Response res) throws ClientProtocolException, IOException, NoAPIKeyException {

    CloseableHttpClient httpclient = HttpClients.createDefault();

    HttpPost post = new HttpPost("https://discordapp.com/api/oauth2/token");
    List<NameValuePair> nvp = new ArrayList<NameValuePair>();
    nvp.add(new BasicNameValuePair("client_id", Bot.getInstance().getApiKeys().get("dashboardid")));
    nvp.add(new BasicNameValuePair("client_secret", Bot.getInstance().getApiKeys().get("dashboardsecret")));
    nvp.add(new BasicNameValuePair("grant_type", "authorization_code"));
    nvp.add(new BasicNameValuePair("code", token));

    post.setEntity(new UrlEncodedFormEntity(nvp));

    String accessToken;
    CloseableHttpResponse response = httpclient.execute(post);
    try {
        System.out.println(response.getStatusLine());
        HttpEntity entity = response.getEntity();
        JsonObject authJson;
        try(BufferedReader buffer = new BufferedReader(new InputStreamReader(entity.getContent()))) {
            authJson = Json.parse(buffer.lines().collect(Collectors.joining("\n"))).asObject();
        }
        accessToken = authJson.getString("access_token", "");
        EntityUtils.consume(entity);
        getGuilds(res, accessToken);
    } finally {
        response.close();
    }
}
项目:Huochexing12306    文件:A6OrderAty.java   
private boolean returnTicket(BookingInfo bInfo) {
    String url = "https://kyfw.12306.cn/otn/queryOrder/returnTicket";
    List<NameValuePair> lstParams = new ArrayList<NameValuePair>();
    lstParams.add(new BasicNameValuePair("_json_att", ""));
    try {
        String strHtml = bInfo
                .getHttpHelper()
                .post(A6Util
                        .makeRefererColl("https://kyfw.12306.cn/otn/queryOrder/init"),
                        url, lstParams);
        if (strHtml != null && strHtml.indexOf("退票成功") > 0) {
            return true;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
项目:ts-benchmark    文件:InfluxDB2.java   
private void createTestDB() {
        HttpClient hc = getHttpClient();
        HttpPost post = new HttpPost(QUERY_URL);
        HttpResponse response = null;
        try {
            List<NameValuePair> nameValues = new ArrayList<NameValuePair>();
            String createSql = "CREATE DATABASE " + DB_NAME;
            NameValuePair nameValue = new BasicNameValuePair("q", createSql);
            nameValues.add(nameValue);
            HttpEntity entity = new UrlEncodedFormEntity(nameValues, "utf-8");
            post.setEntity(entity);
            response = hc.execute(post);
            closeHttpClient(hc);
//          System.out.println(response);
        } catch (Exception e) {
            e.printStackTrace();
        }finally{
            closeResponse(response);
            closeHttpClient(hc);
        }
    }
项目:letv    文件:PayCenterApi.java   
public String requestHongkongOrder(String productid, String pid, String price, String product_name, String product_desc, String merchant_business_id, String callBackUrl) {
    String head = getNormalDynamicUrl();
    ArrayList<BasicNameValuePair> params = new ArrayList();
    params.add(new BasicNameValuePair("mod", "iappay"));
    params.add(new BasicNameValuePair("ctl", "index"));
    params.add(new BasicNameValuePair(SocialConstants.PARAM_ACT, "orderId"));
    params.add(new BasicNameValuePair("productid", productid));
    params.add(new BasicNameValuePair("username", PreferencesManager.getInstance().getUserName()));
    params.add(new BasicNameValuePair("pid", pid));
    params.add(new BasicNameValuePair("uid", PreferencesManager.getInstance().getUserId()));
    params.add(new BasicNameValuePair("price", price));
    params.add(new BasicNameValuePair("itemamt", price));
    params.add(new BasicNameValuePair("product_name", product_name));
    params.add(new BasicNameValuePair("product_desc", product_desc));
    params.add(new BasicNameValuePair("merchant_business_id", merchant_business_id));
    params.add(new BasicNameValuePair("my_order_type", "WAP"));
    params.add(new BasicNameValuePair("call_back_url", callBackUrl));
    params.add(new BasicNameValuePair("channel_ids", ""));
    params.add(new BasicNameValuePair("companyurl", ""));
    params.add(new BasicNameValuePair("pcode", LetvConfig.getPcode()));
    params.add(new BasicNameValuePair("version", LetvUtils.getClientVersionName()));
    params.add(new BasicNameValuePair("markid", ""));
    return ParameterBuilder.getQueryUrl(params, head);
}
项目:letv    文件:UserCenterApi.java   
public String getSendChatBarrageMessage(String roomId, String message, String tk, boolean forhost, String tm, String color, String font, String position, String from) {
    String keyb = roomId + "," + tm + "," + LetvConstant.CHAT_KEY;
    ArrayList<BasicNameValuePair> params = new ArrayList();
    params.add(new BasicNameValuePair("luamod", "main"));
    params.add(new BasicNameValuePair("mod", HOME_RECOMMEND_PARAMETERS.MOD_VALUE));
    params.add(new BasicNameValuePair("ctl", "chatSendmessage"));
    params.add(new BasicNameValuePair(SocialConstants.PARAM_ACT, "index"));
    params.add(new BasicNameValuePair("color", color));
    params.add(new BasicNameValuePair("font", font));
    params.add(new BasicNameValuePair("position", position));
    params.add(new BasicNameValuePair("from", from));
    params.add(new BasicNameValuePair("roomId", roomId));
    params.add(new BasicNameValuePair("message", message));
    params.add(new BasicNameValuePair("tm", tm));
    params.add(new BasicNameValuePair("key", MD5.toMd5(keyb)));
    params.add(new BasicNameValuePair(MODIFYPWD_PARAMETERS.TK_KEY, tk));
    params.add(new BasicNameValuePair("forhost", String.valueOf(forhost)));
    params.add(new BasicNameValuePair("pcode", LetvConfig.getPcode()));
    params.add(new BasicNameValuePair("version", LetvUtils.getClientVersionName()));
    LogInfo.log("clf", "发送聊天消息getSendChatMessage..url=" + ParameterBuilder.getQueryUrl(params, getDynamicUrl()));
    return ParameterBuilder.getQueryUrl(params, getDynamicUrl());
}
项目:RoadLab-Pro    文件:HockeySender.java   
@Override
public void send(CrashReportData report) throws ReportSenderException {
  String log = createCrashLog(report);
  String url = BASE_URL + ACRA.getConfig().formKey() + CRASHES_PATH;

  try {
    DefaultHttpClient httpClient = new DefaultHttpClient(); 
    HttpPost httpPost = new HttpPost(url);

    List<NameValuePair> parameters = new ArrayList<NameValuePair>(); 
    parameters.add(new BasicNameValuePair("raw", log));
    parameters.add(new BasicNameValuePair("userID", report.get(ReportField.INSTALLATION_ID)));
    parameters.add(new BasicNameValuePair("contact", report.get(ReportField.USER_EMAIL)));
    parameters.add(new BasicNameValuePair("description", report.get(ReportField.USER_COMMENT)));

    httpPost.setEntity(new UrlEncodedFormEntity(parameters, HTTP.UTF_8));

    httpClient.execute(httpPost);   
  }
  catch (Exception e) {
    e.printStackTrace();
  } 
}
项目:letv    文件:PlayRecordApi.java   
public String requestGetverificationCode(int updataId, String key, String tm) {
    String requestUrl = UrlConstdata.getDynamicUrl();
    List<BasicNameValuePair> list = new ArrayList();
    list.add(new BasicNameValuePair("luamod", "main"));
    list.add(new BasicNameValuePair("mod", HOME_RECOMMEND_PARAMETERS.MOD_VALUE));
    list.add(new BasicNameValuePair("ctl", "getCaptcha"));
    list.add(new BasicNameValuePair(SocialConstants.PARAM_ACT, "index"));
    list.add(new BasicNameValuePair("key", key));
    list.add(new BasicNameValuePair("tm", tm));
    list.add(new BasicNameValuePair("pcode", LetvConfig.getPcode()));
    list.add(new BasicNameValuePair("version", LetvUtils.getClientVersionName()));
    Log.e("ZSM", "requestGetverificationCode url == " + ParameterBuilder.getQueryUrl(list, requestUrl));
    return ParameterBuilder.getQueryUrl(list, requestUrl);
}
项目:hack_sjtu_2017    文件:HttpHandler.java   
public void PostTask(String id, TextParser.EArticleType type, Score score) throws Exception {
    List<BasicNameValuePair> parameters = new ArrayList<>();
    parameters.add(new BasicNameValuePair("type", Integer.toString(type.ordinal())));
    parameters.add(new BasicNameValuePair("content_id", id));
    System.out.println(score.ToJson(0).toString());
    parameters.add(new BasicNameValuePair("score", score.ToJson(0).toString()));

    PostParam(postTaskURL, parameters);
}
项目:boohee_v5.6    文件:AuthorizeApi.java   
public static String doHttpGet(Context context, String path, long clientId, String
        accessToken) throws XMAuthericationException {
    List<NameValuePair> params = new ArrayList();
    params.add(new BasicNameValuePair("clientId", String.valueOf(clientId)));
    params.add(new BasicNameValuePair("token", accessToken));
    try {
        return Network.downloadXml(context, new URL(AuthorizeHelper.generateUrl(HTTP_PROTOCOL
                + HOST + path, params)), null, null, null, null);
    } catch (Throwable e) {
        throw new XMAuthericationException(e);
    } catch (Throwable e2) {
        throw new XMAuthericationException(e2);
    }
}
项目:pnc-repressurized    文件:PastebinHandler.java   
public boolean loginInternal(String userName, String password) {
    HttpPost httppost = new HttpPost("http://pastebin.com/api/api_login.php");

    List<NameValuePair> params = new ArrayList<NameValuePair>(3);
    params.add(new BasicNameValuePair("api_dev_key", DEV_KEY));
    params.add(new BasicNameValuePair("api_user_name", userName));
    params.add(new BasicNameValuePair("api_user_password", password));
    try {
        httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity entity = response.getEntity();
        if (entity != null) {
            InputStream instream = entity.getContent();
            userKey = IOUtils.toString(instream, "UTF-8");
            if (userKey.startsWith("Bad API request")) {
                Log.warning("User tried to log in into pastebin, it responded with the following: " + userKey);
                userKey = null;
                return false;
            }
            return true;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
项目:letv    文件:LetvUrlMaker.java   
public static String getNetIPAddress() {
    String requestUrl = getDynamicHead();
    List<BasicNameValuePair> list = new ArrayList();
    list.add(new BasicNameValuePair("mod", HOME_RECOMMEND_PARAMETERS.MOD_VALUE));
    list.add(new BasicNameValuePair("ctl", "ip"));
    list.add(new BasicNameValuePair(SocialConstants.PARAM_ACT, "index"));
    list.add(new BasicNameValuePair("pcode", LetvConfig.getPcode()));
    list.add(new BasicNameValuePair("version", LetvUtils.getClientVersionName()));
    return ParameterBuilder.getQueryUrl(list, requestUrl);
}
项目:letv    文件:LetvUrlMaker.java   
public static String getDialogMsgInfoUrl(String markId) {
    List<BasicNameValuePair> list = new ArrayList();
    list.add(new BasicNameValuePair("mod", "minfo"));
    list.add(new BasicNameValuePair("ctl", "message"));
    list.add(new BasicNameValuePair(SocialConstants.PARAM_ACT, "index"));
    list.add(new BasicNameValuePair("markid", markId));
    list.add(new BasicNameValuePair("pcode", LetvConfig.getPcode()));
    list.add(new BasicNameValuePair("version", LetvUtils.getClientVersionName()));
    return ParameterBuilder.getPathUrl(list, getStaticHead(), UrlConstdata.getStaticEnd());
}