Example usage for org.apache.http.message BasicNameValuePair BasicNameValuePair

List of usage examples for org.apache.http.message BasicNameValuePair BasicNameValuePair

Introduction

In this page you can find the example usage for org.apache.http.message BasicNameValuePair BasicNameValuePair.

Prototype

public BasicNameValuePair(String str, String str2) 

Source Link

Usage

From source file:googleranking.processing.GoogleData.java

public Document getGoogleHtml() {
    Document doc;/*  ww w  .ja v  a 2 s  . c o m*/
    try {
        URIBuilder search_builder = new URIBuilder(GOOGLE_SEARCH_WEB);
        List<NameValuePair> search_query = new ArrayList<NameValuePair>(2);
        search_query.add(new BasicNameValuePair("pws", "0"));
        search_query.add(new BasicNameValuePair("filter", "1"));
        search_query.add(new BasicNameValuePair("hl", "jp"));
        search_query.add(new BasicNameValuePair("num", Integer.toString(50)));
        search_query.add(new BasicNameValuePair("q", keyWord));
        search_query.add(new BasicNameValuePair("start", "0"));

        String search_url = search_builder.addParameters(search_query).build().toString();

        URIBuilder middle_builder = new URIBuilder(MIDDLE_SERVER);
        List<NameValuePair> middle_query = new ArrayList<NameValuePair>(2);
        middle_query.add(new BasicNameValuePair("url", search_url));
        middle_query.add(new BasicNameValuePair("ip", "49.212.93.235"));

        String url = middle_builder.addParameters(middle_query).build().toString();

        return Jsoup.connect(url).userAgent("Mozilla").get();
    } catch (IOException ex) {
        Logger.getLogger(GoogleData.class.getName()).log(Level.SEVERE, null, ex);
    } catch (URISyntaxException ex) {
        Logger.getLogger(GoogleData.class.getName()).log(Level.SEVERE, null, ex);
    }
    return null;
}

From source file:dk.i2m.drupal.field.wrapper.BasicWrapper.java

@Override
public Set<NameValuePair> setup(String language, Set<NameValuePair> nvps) {
    nvps.add(new BasicNameValuePair(name, basic.getValue()));
    return nvps;//  w w w  .j  a  v  a2  s  . c  om
}

From source file:com.fufang.testcase.orgmanager.warnset.SaveOrUpdate.java

@Test
public void saveWarn() throws IOException, URISyntaxException, SQLException {

    List<NameValuePair> nvps = new ArrayList<NameValuePair>();
    nvps.add(new BasicNameValuePair("jsonStr",
            "{\"warnBeanList\": [{\"warnType\": \"32\",\"warnGspType\": 3,\"licenseId\":\"77\",\"isOn\":1,\"dayNum\":30,\"maintainDay\": 90,\"roles\":\"B6E58291-0A5B-49A3-B379-19DAC845789F\"}]}"));

    String result = HttpPostLogin.httpPost(testUrl, nvps, loginUrl, userName, pwd);

    JSONObject jsonObject = JSONObject.fromObject(result);
    int state = jsonObject.getInt("state");
    String msg = jsonObject.getString("msg");
    System.out.println(state + " - " + msg);

    Assert.assertEquals(200, state);//w w w.  j  ava 2s  . c o  m
    Assert.assertEquals("success", msg);

    SqlUtils c = new SqlUtils();
    con = c.sqlSConnection(dbUrl, dbName, dbUserName, dbPassword);

    try {
        Statement statement = con.createStatement();

        String querySqlU = "SELECT * FROM [dbo].[t_warn] WHERE roles ='B6E58291-0A5B-49A3-B379-19DAC845789F'";
        ResultSet resultSetU = statement.executeQuery(querySqlU);

        while (resultSetU.next()) {
            setId(resultSetU.getInt("id"));
            String warnType = resultSetU.getString("warnType");
            Assert.assertEquals("32", warnType);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:model.web.ClientHttp.java

public Response ping() throws Exception {
    ArrayList<NameValuePair> params = new ArrayList<>();
    params.add(new BasicNameValuePair(HttpMetods.METHOD, HttpMetods.PING));
    return new ClientHandler().getResponse(execute(params));

    //return new ClientHandler().getResponse(executeGet(params));
}

From source file:com.mediaportal.ampdroid.api.JsonUtils.java

public static BasicNameValuePair newPair(String _name, Date _value) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(_value);/*from  w ww. j av  a  2s .c om*/
    int offset = (int) ((cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)) / 60000);

    cal.add(Calendar.MINUTE, offset);
    String dateString = IsoDate.dateToString(cal.getTime(), IsoDate.DATE_TIME);

    return new BasicNameValuePair(_name, dateString);
}

From source file:com.Kuesty.services.RequestTask.java

public RequestTask addHeader(String name, String value) {
    if (null == headers) {
        headers = new ArrayList<NameValuePair>();
    }/*from w  ww . j ava 2 s .c o m*/
    headers.add(new BasicNameValuePair(name, value));
    return this;
}

From source file:org.deviceconnect.android.manager.util.DConnectUtil.java

/**
 * ??URI??./*from   ww  w .  j a  v  a 2 s.  co  m*/
 * @param uri ??ContentUri
 * @return URI
 */
public static String createUri(final String uri) {
    DConnectSettings settings = DConnectSettings.getInstance();
    URIBuilder builder = new URIBuilder();
    if (settings.isSSL()) {
        builder.setScheme("https");
    } else {
        builder.setScheme("http");
    }
    builder.setHost(settings.getHost());
    builder.setPort(settings.getPort());
    builder.setProfile(DConnectFilesProfile.PROFILE_NAME);

    ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("uri", uri));
    builder.setParameters(params);

    return builder.toString();
}

From source file:com.jzc.rfid.cl.listeners.RFIDTagGainListener.java

public void tagGained(TagGainEvent tagGainEvent) {
    System.out.println(Main.readerId + " " + tagGainEvent.getValue());
    final String tagValue = tagGainEvent.getValue();
    new Thread(new Runnable() {
        public void run() {
            try {
                List<NameValuePair> qparams = new ArrayList<NameValuePair>();
                qparams.add(new BasicNameValuePair("cardId", tagValue));
                qparams.add(new BasicNameValuePair("readerId", Integer.toString(Main.readerId)));
                String url = "http://www.electric20.com/thermaPref/cardEvent.php";
                HttpPost httpPost = new HttpPost(url);
                httpPost.setEntity(new UrlEncodedFormEntity(qparams, HTTP.UTF_8));
                HttpClient httpClient = new DefaultHttpClient();
                //HttpHost proxy = new HttpHost("mainproxy.nottingham.ac.uk",8080);
                //httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
                httpClient.execute(httpPost);
                httpClient.getConnectionManager().closeExpiredConnections();
                System.out.println(httpPost.getURI());
            } catch (Exception e) {
                e.printStackTrace();/*ww  w.j a  v  a2s  .co m*/
            }
        }
    }).start();
    try {
        rfid.setLEDOn(!rfid.getLEDOn());
    } catch (PhidgetException e) {
        e.printStackTrace();
    }
}

From source file:models.ModelStudentLocation.java

@SuppressWarnings("unused")
public void save() {
    ArrayList<NameValuePair> http_parameters;
    http_parameters = new ArrayList<>();

    http_parameters.add(new BasicNameValuePair("first_name", first_name));
    http_parameters.add(new BasicNameValuePair("last_name", last_name));
    http_parameters.add(new BasicNameValuePair("phone", phone_number));
    http_parameters.add(new BasicNameValuePair("latitude", latitude));
    http_parameters.add(new BasicNameValuePair("longitude", longitude));
    http_parameters.add(new BasicNameValuePair("service", services));
    http_parameters.add(new BasicNameValuePair("license", vehicle_license_number));
    http_parameters.add(new BasicNameValuePair("vehicle_year", Integer.toString(vehicle_year)));
    http_parameters.add(new BasicNameValuePair("vehicle_make", vehicle_make));

    SimpleNetwork.send("PUT", "student_location/send/format/json", http_parameters, null, "");
}

From source file:com.pocketsoap.convodroid.http.ChatterRequests.java

public static RestRequest markConversationRead(String conversationUrl) {
    try {/*from   w  ww  .j  a  v  a  2s  .  co  m*/
        UrlEncodedFormEntity form = new UrlEncodedFormEntity(
                Arrays.asList(new NameValuePair[] { new BasicNameValuePair("read", "true") }), "UTF-8");
        return new RestRequest(RestMethod.POST, conversationUrl + "/mark-read", form, HTTP_HEADERS);
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }
}