org.apache.http.message.BasicNameValuePair Java Examples

The following examples show how to use org.apache.http.message.BasicNameValuePair. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TempletonDemo.java    From knox with Apache License 2.0 6 votes vote down vote up
private void demo( String url ) throws IOException {
  List<NameValuePair> parameters = new ArrayList<>();
  parameters.add( new BasicNameValuePair( "user.name", "hdfs" ) );
  parameters.add( new BasicNameValuePair( "jar", "wordcount/org.apache.hadoop-examples.jar" ) );
  parameters.add( new BasicNameValuePair( "class", "org.apache.org.apache.hadoop.examples.WordCount" ) );
  parameters.add( new BasicNameValuePair( "arg", "wordcount/input" ) );
  parameters.add( new BasicNameValuePair( "arg", "wordcount/output" ) );
  UrlEncodedFormEntity entity = new UrlEncodedFormEntity( parameters, StandardCharsets.UTF_8 );
  HttpPost request = new HttpPost( url );
  request.setEntity( entity );

  HttpClientBuilder builder = HttpClientBuilder.create();
  CloseableHttpClient client = builder.build();
  HttpResponse response = client.execute( request );
  System.out.println( EntityUtils.toString( response.getEntity() ) );
}
 
Example #2
Source File: SimpleRestClient.java    From canvas-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static List<NameValuePair> convertParameters(final Map<String, List<String>> parameterMap) {
    final List<NameValuePair> params = new ArrayList<>();

    if (parameterMap == null) {
        return params;
    }

    for (final Map.Entry<String, List<String>> param : parameterMap.entrySet()) {
        final String key = param.getKey();
        if(param.getValue() == null || param.getValue().isEmpty()) {
            params.add(new BasicNameValuePair(key, null));
            LOG.debug("key: " + key + "\tempty value");
        }
        for (final String value : param.getValue()) {
            params.add(new BasicNameValuePair(key, value));
            LOG.debug("key: "+ key +"\tvalue: " + value);
        }
    }
    return params;
}
 
Example #3
Source File: ActionRunner.java    From curly with Apache License 2.0 6 votes vote down vote up
private void addPostParams(HttpEntityEnclosingRequestBase request) throws UnsupportedEncodingException {
    final MultipartEntityBuilder multipartBuilder = MultipartEntityBuilder.create();
    List<NameValuePair> formParams = new ArrayList<>();
    postVariables.forEach((name, values) -> values.forEach(value -> {
        if (multipart) {
            if (value.startsWith("@")) {
                File f = new File(value.substring(1));
                multipartBuilder.addBinaryBody(name, f, ContentType.DEFAULT_BINARY, f.getName());
            } else {
                multipartBuilder.addTextBody(name, value);
            }
        } else {
            formParams.add(new BasicNameValuePair(name, value));
        }
    }));
    if (multipart) {
        request.setEntity(multipartBuilder.build());
    } else {
        request.setEntity(new UrlEncodedFormEntity(formParams));
    }
}
 
Example #4
Source File: StoreRem.java    From openprodoc with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 *
 * @param Id
 * @param Ver
 * @return
 * @throws PDException
 */
@Override
protected InputStream Retrieve(String Id, String Ver, Record Rec) throws PDException
{
VerifyId(Id);
CloseableHttpResponse response2 = null;
try {
List <NameValuePair> nvps = new ArrayList <NameValuePair>();
nvps.add(new BasicNameValuePair(ORDER, DriverRemote.S_RETRIEVEFILE));
nvps.add(new BasicNameValuePair(DriverRemote.PARAM, "<OPD><Id>"+Id+"</Id><Ver>"+Ver+"</Ver></OPD>"));
UrlPost.setEntity(new UrlEncodedFormEntity(nvps));
response2 = httpclient.execute(UrlPost, context);
HttpEntity Resp=response2.getEntity();
return(Resp.getContent());
} catch (Exception ex)
    {
    PDException.GenPDException("Error_retrieving_content", ex.getLocalizedMessage());
    }
return (null); 
}
 
Example #5
Source File: GameClient.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
private void postLeaveInstance() {
  AsyncCallbackPair<JSONObject> setInstanceCallback = new AsyncCallbackPair<JSONObject>(){
    public void onSuccess(final JSONObject response) {
      SetInstance("");
      processInstanceLists(response);
      FunctionCompleted("LeaveInstance");
    }
    public void onFailure(final String message) {
      WebServiceError("LeaveInstance", message);
    }
  };

  postCommandToGameServer(LEAVE_INSTANCE_COMMAND,
      Lists.<NameValuePair>newArrayList(
          new BasicNameValuePair(GAME_ID_KEY, GameId()),
          new BasicNameValuePair(INSTANCE_ID_KEY, InstanceId()),
          new BasicNameValuePair(PLAYER_ID_KEY, UserEmailAddress())),
          setInstanceCallback);
}
 
Example #6
Source File: TieBaApi.java    From tieba-api with MIT License 6 votes vote down vote up
/**
 * 移除粉丝
 * @param bduss bduss
 * @param fans_uid 用户id
 * @return 结果
 */
public String removeFans(String bduss, String fans_uid){
	List<NameValuePair> list = new ArrayList<NameValuePair>();
	list.add(new BasicNameValuePair("BDUSS", bduss));
	list.add(new BasicNameValuePair("_client_id", "wappc_1542694366490_105"));
	list.add(new BasicNameValuePair("_client_type", "2"));
	list.add(new BasicNameValuePair("_client_version", "9.8.8.13"));
	list.add(new BasicNameValuePair("fans_uid", fans_uid));
	list.add(new BasicNameValuePair("tbs", getTbs(bduss)));
	list.add(new BasicNameValuePair("timestamp", System.currentTimeMillis()+""));
	list.add(new BasicNameValuePair("sign", StrKit.md5Sign(list)));
	try {
		HttpResponse response = hk.execute(Constants.REMOVE_FANS, null, list);
		return EntityUtils.toString(response.getEntity());
	} catch (Exception e) {
		logger.error(e.getMessage(), e);
	}
	return "";
}
 
Example #7
Source File: BasicHttpClient.java    From zerocode with Apache License 2.0 6 votes vote down vote up
/**
 * This is how framework makes the KeyValue pair when "application/x-www-form-urlencoded" headers
 * is passed in the request.  In case you want to build or prepare the requests differently,
 * you can override this method via @UseHttpClient(YourCustomHttpClient.class).
 *
 * @param httpUrl
 * @param methodName
 * @param reqBodyAsString
 * @return
 * @throws IOException
 */
public RequestBuilder createFormUrlEncodedRequestBuilder(String httpUrl, String methodName, String reqBodyAsString) throws IOException {
    RequestBuilder requestBuilder = RequestBuilder
            .create(methodName)
            .setUri(httpUrl);
    if (reqBodyAsString != null) {
        Map<String, Object> reqBodyMap = HelperJsonUtils.readObjectAsMap(reqBodyAsString);
        List<NameValuePair> reqBody = new ArrayList<>();
         for(String key : reqBodyMap.keySet()) {
             reqBody.add(new BasicNameValuePair(key, reqBodyMap.get(key).toString()));
         }
         HttpEntity httpEntity = new UrlEncodedFormEntity(reqBody);
         requestBuilder.setEntity(httpEntity);
        requestBuilder.setHeader(CONTENT_TYPE, APPLICATION_FORM_URL_ENCODED);
    }
    return requestBuilder;
}
 
Example #8
Source File: LetvUrlMaker.java    From letv with Apache License 2.0 6 votes vote down vote up
public static String getLiveVideoDataUrl(String channelType, String startDate, String endDate, String status, String hasPay, String order, String belongArea) {
    List<BasicNameValuePair> list = new ArrayList();
    list.add(new BasicNameValuePair("luamod", "main"));
    list.add(new BasicNameValuePair("mod", "live"));
    list.add(new BasicNameValuePair("ctl", "getChannelliveBystatus"));
    list.add(new BasicNameValuePair(SocialConstants.PARAM_ACT, "index"));
    list.add(new BasicNameValuePair(a.e, LetvConfig.getHKClientID()));
    list.add(new BasicNameValuePair("beginDate", startDate));
    list.add(new BasicNameValuePair("ct", channelType));
    list.add(new BasicNameValuePair("endDate", endDate));
    list.add(new BasicNameValuePair("status", status));
    list.add(new BasicNameValuePair("belongArea", belongArea));
    list.add(new BasicNameValuePair("order", order));
    list.add(new BasicNameValuePair("hasPay", hasPay));
    list.add(new BasicNameValuePair("pcode", LetvConfig.getPcode()));
    list.add(new BasicNameValuePair("version", LetvUtils.getClientVersionName()));
    return ParameterBuilder.getQueryUrl(list, getLiveHKDynamicUrl());
}
 
Example #9
Source File: LetvUrlMaker.java    From letv with Apache License 2.0 6 votes vote down vote up
public static String getVideolistUrl(String aid, String vid, String page, String count, String o, String merge) {
    String head = getStaticHead();
    String end = LetvHttpApiConfig.getStaticEnd();
    ArrayList<BasicNameValuePair> params = new ArrayList();
    params.add(new BasicNameValuePair("mod", HOME_RECOMMEND_PARAMETERS.MOD_VALUE));
    params.add(new BasicNameValuePair("ctl", "videolist"));
    params.add(new BasicNameValuePair(SocialConstants.PARAM_ACT, "detail"));
    params.add(new BasicNameValuePair("id", aid));
    params.add(new BasicNameValuePair("vid", vid));
    params.add(new BasicNameValuePair(PAGE.MYSHARE, page));
    params.add(new BasicNameValuePair("s", count));
    params.add(new BasicNameValuePair("o", o));
    params.add(new BasicNameValuePair(PAGE.MYLETV, merge));
    params.add(new BasicNameValuePair("pcode", LetvUtils.getPcode()));
    params.add(new BasicNameValuePair("version", LetvUtils.getClientVersionName()));
    return ParameterBuilder.getPathUrl(params, head, end);
}
 
Example #10
Source File: HTTPUtil.java    From simple-sso with Apache License 2.0 6 votes vote down vote up
/**
 * 向目标url发送post请求
 * 
 * @author sheefee
 * @date 2017年9月12日 下午5:10:36
 * @param url
 * @param params
 * @return boolean
 */
public static boolean post(String url, Map<String, String> params) {
	CloseableHttpClient httpclient = HttpClients.createDefault();
	HttpPost httpPost = new HttpPost(url);
	// 参数处理
	if (params != null && !params.isEmpty()) {
		List<NameValuePair> list = new ArrayList<NameValuePair>();
		
		Iterator<Entry<String, String>> it = params.entrySet().iterator();
		while (it.hasNext()) {
			Entry<String, String> entry = it.next();
			list.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
		}
		
		httpPost.setEntity(new UrlEncodedFormEntity(list, Consts.UTF_8));
	}
	// 执行请求
	try {
		CloseableHttpResponse response = httpclient.execute(httpPost);
		response.getStatusLine().getStatusCode();
	} catch (Exception e) {
		e.printStackTrace();
	}
	return true;
}
 
Example #11
Source File: GeoServerIT.java    From geowave with Apache License 2.0 6 votes vote down vote up
private HttpPost createWFSTransaction(
    final HttpClient httpclient,
    final String version,
    final BasicNameValuePair... paramTuples) throws Exception {
  final HttpPost command = new HttpPost(WFS_URL_PREFIX + "/Transaction");

  final ArrayList<BasicNameValuePair> postParameters = new ArrayList<>();
  postParameters.add(new BasicNameValuePair("version", version));
  postParameters.add(
      new BasicNameValuePair("typename", ServicesTestEnvironment.TEST_WORKSPACE + ":geostuff"));
  Collections.addAll(postParameters, paramTuples);

  command.setEntity(new UrlEncodedFormEntity(postParameters));

  command.setHeader("Content-type", "text/xml");
  command.setHeader("Accept", "text/xml");

  return command;
}
 
Example #12
Source File: ParameterEchoTestCase.java    From quarkus-http with Apache License 2.0 6 votes vote down vote up
@Test
public void testPostInStream() throws IOException {
    TestHttpClient client = new TestHttpClient();
    try {
        HttpPost post = new HttpPost(DefaultServer.getDefaultServerURL() + "/servletContext/aaa");
        final List<NameValuePair> values = new ArrayList<>();
        values.add(new BasicNameValuePair("param1", "1"));
        values.add(new BasicNameValuePair("param2", "2"));
        values.add(new BasicNameValuePair("param3", "3"));
        UrlEncodedFormEntity data = new UrlEncodedFormEntity(values, "UTF-8");
        post.setEntity(data);
        HttpResponse result = client.execute(post);
        Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode());
        final String response = HttpClientUtils.readResponse(result);
        Assert.assertEquals(RESPONSE, response);
    } finally {
        client.getConnectionManager().shutdown();
    }
}
 
Example #13
Source File: PlayRecordApi.java    From letv with Apache License 2.0 6 votes vote down vote up
public String getPlayTraces(int updataId, String uid, String page, String pagesize, 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, "get"));
    list.add(new BasicNameValuePair("imei", LetvUtils.getIMEI()));
    list.add(new BasicNameValuePair("mac", LetvUtils.getMacAddress()));
    list.add(new BasicNameValuePair("uid", uid));
    list.add(new BasicNameValuePair(MyDownloadActivityConfig.PAGE, page));
    list.add(new BasicNameValuePair("pagesize", pagesize));
    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);
}
 
Example #14
Source File: AzkabanWorkflowClient.java    From dr-elephant with Apache License 2.0 6 votes vote down vote up
/**
 * Authenticates Dr. Elephant in Azkaban and sets the sessionId
 *
 * @param userName The username of the user
 * @param password The password of the user
 */
@Override
public void login(String userName, String password) {
  this._username = userName;
  this._password = password;
  List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
  urlParameters.add(new BasicNameValuePair("action", "login"));
  urlParameters.add(new BasicNameValuePair("username", userName));
  urlParameters.add(new BasicNameValuePair("password", password));

  try {
    JSONObject jsonObject = fetchJson(urlParameters, _workflowExecutionUrl);
    if (!jsonObject.has("session.id")) {
      throw new RuntimeException("Login attempt failed. The session ID could not be obtained.");
    }
    this._sessionId = jsonObject.get("session.id").toString();
    logger.debug("Session ID is " + this._sessionId);
  } catch (JSONException e) {
    e.printStackTrace();
  }
}
 
Example #15
Source File: BrooklynPropertiesSecurityFilterTest.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@Test(groups = {"Integration","Broken"})
public void testInteractionOfSecurityFilterAndFormMapProvider() throws Exception {
    Stopwatch stopwatch = Stopwatch.createStarted();
    try {
        Server server = useServerForTest(baseLauncher()
                .forceUseOfDefaultCatalogWithJavaClassPath(true)
                .withoutJsgui()
                .start());
        String appId = startAppAtNode(server);
        String entityId = getTestEntityInApp(server, appId);
        HttpClient client = HttpTool.httpClientBuilder()
                .uri(getBaseUriRest())
                .build();
        List<? extends NameValuePair> nvps = Lists.newArrayList(
                new BasicNameValuePair("arg", "bar"));
        String effector = String.format("/applications/%s/entities/%s/effectors/identityEffector", appId, entityId);
        HttpToolResponse response = HttpTool.httpPost(client, URI.create(getBaseUriRest() + effector),
                ImmutableMap.of(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.getMimeType()),
                URLEncodedUtils.format(nvps, Charsets.UTF_8).getBytes());

        LOG.info("Effector response: {}", response.getContentAsString());
        assertTrue(HttpTool.isStatusCodeHealthy(response.getResponseCode()), "response code=" + response.getResponseCode());
    } finally {
        LOG.info("testInteractionOfSecurityFilterAndFormMapProvider complete in " + Time.makeTimeStringRounded(stopwatch));
    }
}
 
Example #16
Source File: GooglePlayAPI.java    From raccoon4 with Apache License 2.0 6 votes vote down vote up
/**
 * Executes POST request on given URL with POST parameters and header
 * parameters.
 */
private HttpEntity executePost(String url, String[][] postParams,
		String[][] headerParams) throws IOException {

	List<NameValuePair> formparams = new ArrayList<NameValuePair>();

	for (String[] param : postParams) {
		if (param[0] != null && param[1] != null) {
			formparams.add(new BasicNameValuePair(param[0], param[1]));
		}
	}

	UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams, "UTF-8");

	return executePost(url, entity, headerParams);
}
 
Example #17
Source File: HttpDriverTest.java    From athenz with Apache License 2.0 6 votes vote down vote up
@Test
public void testDoPost201() throws IOException {
    CloseableHttpClient httpClient = Mockito.mock(CloseableHttpClient.class);
    CloseableHttpResponse httpResponse = Mockito.mock(CloseableHttpResponse.class);
    HttpEntity entity = Mockito.mock(HttpEntity.class);

    String data = "Sample Server Response";

    Mockito.when(httpResponse.getStatusLine()).thenReturn(new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_CREATED, "OK" ));
    Mockito.when(entity.getContent()).thenReturn(new ByteArrayInputStream(data.getBytes()));
    Mockito.when(httpResponse.getEntity()).thenReturn(entity);
    Mockito.when(httpClient.execute(Mockito.any(HttpPost.class))).thenReturn(httpResponse);

    HttpDriver httpDriver = new HttpDriver.Builder("", null, "asdf".toCharArray(), null, null)
            .build();
    httpDriver.setHttpClient(httpClient);

    List<NameValuePair> params = new ArrayList<>();
    params.add(new BasicNameValuePair("data", "value"));

    String url = "https://localhost:4443/sample";

    String out = httpDriver.doPost(url, params);
    Assert.assertEquals(out, data);
}
 
Example #18
Source File: TieBaApi.java    From tieba-api with MIT License 6 votes vote down vote up
/**
 * 名人堂助攻
 * @param bduss bduss
 * @param tbName 贴吧名称
 * @param tbs tbs
 * @return 结果
 * no=210009 //不在名人堂
 * no=3110004 //暂未关注
 * no=2280006 //已助攻
 * no=0 //成功
 */
public String support(String bduss, String tbName, String tbs) {
	String suportResult = "";
	try {
		HttpResponse hp = hk.execute(String.format(Constants.TIEBA_URL_HTTPS, tbName));
		if(hp == null) {
			hp = hk.execute(String.format(Constants.TIEBA_URL_HTTP, tbName));
		}
		String fidHtml= EntityUtils.toString(hp.getEntity());
		String fid = StrKit.substring(fidHtml, "forum_id\":", ",");
		String cookie = createCookie(bduss);
		List<NameValuePair> params = new ArrayList<>();
		params.add(new BasicNameValuePair("forum_id", fid));
		params.add(new BasicNameValuePair("tbs", tbs));
		//3.获取npc_id
		String result = EntityUtils.toString(hk.execute(Constants.GET_FORUM_SUPPORT, cookie, params).getEntity());
		String npcId = JSONPath.eval(JSON.parse(result), "$.data[0].npc_info.npc_id").toString();
		params.add(new BasicNameValuePair("npc_id", npcId));
		//3.助攻
		suportResult = EntityUtils.toString(hk.execute(Constants.FORUM_SUPPORT,cookie, params).getEntity());
	} catch (Exception e) {
		logger.error(e.getMessage(), e);
	}
	return suportResult;
}
 
Example #19
Source File: TieBaApi.java    From tieba-api with MIT License 6 votes vote down vote up
/**
 * 获取封禁原因列表
 * @param bduss bduss
 * @param tbName 贴吧名称
 * @param uid 用户uid
 * @return 封禁原因列表
 */
@SuppressWarnings("unchecked")
public List<String> prisionReasonList(String bduss, String tbName, String uid){
	List<String> reasonList = null;
	try {
		List<NameValuePair> list = new ArrayList<NameValuePair>();
		list.add(new BasicNameValuePair("BDUSS", bduss));
		list.add(new BasicNameValuePair("_client_id", "wappc_1451451147094_870"));
		list.add(new BasicNameValuePair("_client_type", "2"));
		list.add(new BasicNameValuePair("_client_version", "6.2.2"));
		list.add(new BasicNameValuePair("_phone_imei", "864587027315606"));
		list.add(new BasicNameValuePair("forum_id", getFid(tbName)));
		list.add(new BasicNameValuePair("user_id", uid));
		list.add(new BasicNameValuePair("sign", StrKit.md5Sign(list)));
		HttpResponse response = hk.execute(Constants.BAWU_POST_URL, createCookie(bduss), list);
		String result = EntityUtils.toString(response.getEntity());
		String code = (String) JsonKit.getInfo("error_code", result);
		if("0".equals(code)){
			reasonList = (List<String>) JsonKit.getInfo("reason", result);
		}
	} catch (Exception e) {
		logger.error(e.getMessage(), e);
	}
	return reasonList;
}
 
Example #20
Source File: ParaDictionary.java    From Kingdee-K3Cloud-Web-Api with GNU General Public License v3.0 5 votes vote down vote up
public UrlEncodedFormEntity toEncodeFormEntity() throws UnsupportedEncodingException {
    List list = new ArrayList();
    try {
        for (Iterator localIterator = keySet().iterator(); localIterator.hasNext();) {
            Object element = localIterator.next();
            String key = (String) element;
            String value = (String) get(key);
            list.add(new BasicNameValuePair(key, value));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    UrlEncodedFormEntity entity = new UrlEncodedFormEntity(list, "UTF-8");
    return entity;
}
 
Example #21
Source File: PayCenterApi.java    From letv with Apache License 2.0 5 votes vote down vote up
public String requestAutoPayWithOneKey(String activityIds, String corderid, String productid, String price, String svip, String autoRenewFlag, String payType) {
    String head = getDynamicUrl();
    String backUrl = ALIPAY_ONE_KEY_BACK_URL;
    String fronturl = ALIPAY_ONE_KEY_FRONT_URL;
    String buyType = "2";
    String pid = "0";
    String apisign = MD5.toMd5("corderid=" + corderid + "&pcode=" + LetvConfig.getPcode() + "&productid=" + productid + "&svip=" + svip + "&userid=" + PreferencesManager.getInstance().getUserId() + "&version=" + LetvUtils.getClientVersionName() + "&poi345");
    ArrayList<BasicNameValuePair> params = new ArrayList();
    params.add(new BasicNameValuePair("mod", "pay"));
    params.add(new BasicNameValuePair("ctl", "payAutorenew"));
    params.add(new BasicNameValuePair(SocialConstants.PARAM_ACT, "index"));
    params.add(new BasicNameValuePair("pcode", LetvConfig.getPcode()));
    params.add(new BasicNameValuePair("version", LetvUtils.getClientVersionName()));
    params.add(new BasicNameValuePair("userid", PreferencesManager.getInstance().getUserId()));
    params.add(new BasicNameValuePair("productid", productid));
    String str = "corderid";
    if (TextUtils.isEmpty(corderid)) {
        corderid = "0";
    }
    params.add(new BasicNameValuePair(str, corderid));
    params.add(new BasicNameValuePair("price", price));
    params.add(new BasicNameValuePair("svip", svip));
    params.add(new BasicNameValuePair("buyType", buyType));
    params.add(new BasicNameValuePair("pid", pid));
    params.add(new BasicNameValuePair("activityIds", activityIds));
    params.add(new BasicNameValuePair("backurl", backUrl));
    params.add(new BasicNameValuePair("fronturl", fronturl));
    params.add(new BasicNameValuePair("autoRenewFlag", autoRenewFlag));
    params.add(new BasicNameValuePair(MODIFYPWD_PARAMETERS.APISIGN_KEY, apisign));
    params.add(new BasicNameValuePair(AlipayConstant.ALIPAY_PAY_TYPE_MOBILE_ALL_SCREEN_FLAG, payType));
    return ParameterBuilder.getQueryUrl(params, head);
}
 
Example #22
Source File: HttpResetPassTest.java    From blynk-server with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void submitResetPasswordRequest() throws Exception {
    String email = "[email protected]";
    HttpPost resetPassRequest = new HttpPost(httpServerUrl + "/resetPassword");
    List <NameValuePair> nvps = new ArrayList<>();
    nvps.add(new BasicNameValuePair("email", email));
    nvps.add(new BasicNameValuePair("appName", AppNameUtil.BLYNK));
    resetPassRequest.setEntity(new UrlEncodedFormEntity(nvps));

    try (CloseableHttpResponse response = httpclient.execute(resetPassRequest)) {
        assertEquals(200, response.getStatusLine().getStatusCode());
        String data = TestUtil.consumeText(response);
        assertNotNull(data);
        assertEquals("Email was sent.", data);
    }

    String productName = properties.productName;
    verify(holder.mailWrapper).sendHtml(eq(email),
            eq("Password reset request for the " + productName + " app."),
            contains("/landing?token="));

    verify(holder.mailWrapper).sendHtml(eq(email),
            eq("Password reset request for the " + productName + " app."),
            contains("You recently made a request to reset your password for the " + productName + " app. To complete the process, click the link below."));

    verify(holder.mailWrapper).sendHtml(eq(email),
            eq("Password reset request for the " + productName + " app."),
            contains("If you did not request a password reset from " + productName + ", please ignore this message."));
}
 
Example #23
Source File: PoloniexTradingAPIClient.java    From poloniex-api-java with MIT License 5 votes vote down vote up
@Override
public String returnTradeHistory(String currencyPair) {
    List<NameValuePair> additionalPostParams = new ArrayList<>();
    additionalPostParams.add(new BasicNameValuePair("currencyPair", currencyPair == null ? "all" : currencyPair));
    additionalPostParams.add(new BasicNameValuePair("start", PoloniexExchangeService.LONG_LONG_AGO.toString()));
    return returnTradingAPICommandResults("returnTradeHistory", additionalPostParams);
}
 
Example #24
Source File: RequestParams.java    From Android-Basics-Codes with Artistic License 2.0 5 votes vote down vote up
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;
}
 
Example #25
Source File: HeartbeatManager.java    From emissary with Apache License 2.0 5 votes vote down vote up
public static EmissaryResponse getHeartbeat(String fromPlace, String toPlace, EmissaryClient client) {
    final String directoryUrl = KeyManipulator.getServiceHostURL(toPlace);
    final HttpPost method = new HttpPost(directoryUrl + EmissaryClient.CONTEXT + "/Heartbeat.action");
    final String loc = KeyManipulator.getServiceLocation(toPlace);

    final List<NameValuePair> nvps = new ArrayList<NameValuePair>();
    nvps.add(new BasicNameValuePair(HeartbeatAdapter.FROM_PLACE_NAME, fromPlace));
    nvps.add(new BasicNameValuePair(HeartbeatAdapter.TO_PLACE_NAME, loc));
    method.setEntity(new UrlEncodedFormEntity(nvps, java.nio.charset.Charset.defaultCharset()));

    return client.send(method);
}
 
Example #26
Source File: FormDataParserTestCase.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
public void testCase() throws Exception {
    runTest(new BasicNameValuePair("name", "A Value"));
    runTest(new BasicNameValuePair("name", "A Value"), new BasicNameValuePair("Single-value", null));
    runTest(new BasicNameValuePair("name", "A Value"), new BasicNameValuePair("A/name/with_special*chars", "A $ value&& with=SomeCharacters"));
    runTest(new BasicNameValuePair("name", "A Value"), new BasicNameValuePair("Single-value", null), new BasicNameValuePair("A/name/with_special*chars", "A $ value&& with=SomeCharacters"));

}
 
Example #27
Source File: LetvUrlMaker.java    From letv with Apache License 2.0 5 votes vote down vote up
public static String getLiveUrl(String channelId, boolean isPlay) {
    List<BasicNameValuePair> list = new ArrayList();
    list.add(new BasicNameValuePair("luamod", "main"));
    list.add(new BasicNameValuePair("mod", "live"));
    list.add(new BasicNameValuePair("ctl", TaskAddHttpRequest.stream));
    list.add(new BasicNameValuePair(SocialConstants.PARAM_ACT, "index"));
    list.add(new BasicNameValuePair(a.e, LetvConfig.getHKClientID()));
    list.add(new BasicNameValuePair("isPay", isPlay ? "1" : "0"));
    list.add(new BasicNameValuePair("withAllStreams", "1"));
    list.add(new BasicNameValuePair("channelId", channelId));
    list.add(new BasicNameValuePair("pcode", LetvConfig.getPcode()));
    list.add(new BasicNameValuePair("version", LetvUtils.getClientVersionName()));
    return ParameterBuilder.getQueryUrl(list, getLiveHKDynamicUrl());
}
 
Example #28
Source File: LetvUrlMaker.java    From letv with Apache License 2.0 5 votes vote down vote up
public static String getAlbumVideoInfoUrl(String aid) {
    String head = getStaticHead();
    String end = LetvHttpApiConfig.getStaticEnd();
    ArrayList<BasicNameValuePair> params = new ArrayList();
    params.add(new BasicNameValuePair("mod", HOME_RECOMMEND_PARAMETERS.MOD_VALUE));
    params.add(new BasicNameValuePair("ctl", "album"));
    params.add(new BasicNameValuePair("id", aid));
    params.add(new BasicNameValuePair(SocialConstants.PARAM_ACT, "detail"));
    params.add(new BasicNameValuePair("pcode", LetvUtils.getPcode()));
    params.add(new BasicNameValuePair("version", LetvUtils.getClientVersionName()));
    return ParameterBuilder.getPathUrl(params, head, end);
}
 
Example #29
Source File: LetvUrlMaker.java    From letv with Apache License 2.0 5 votes vote down vote up
public static String getLiveWatchNumUrl(String id) {
    List<BasicNameValuePair> list = new ArrayList();
    list.add(new BasicNameValuePair("id", id));
    list.add(new BasicNameValuePair("group", "zhibo"));
    list.add(new BasicNameValuePair("pcode", LetvConfig.getPcode()));
    list.add(new BasicNameValuePair("version", LetvUtils.getClientVersionName()));
    return ParameterBuilder.getQueryUrl(list, getLiveWatchNumHost());
}
 
Example #30
Source File: OkApacheClientStack.java    From AndroidProjects with MIT License 5 votes vote down vote up
@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;
}