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:asynctasks.LoadTicketDataAsync.java

@Override
protected JSONObject doInBackground(String... params) {
    List<NameValuePair> passer = new ArrayList<NameValuePair>();
    passer.add(new BasicNameValuePair("tag", "getdata"));
    JSONObject json = jSerial.getJSONFromUrl(loadDataUrl, "POST", passer);
    return json;//from   w  w  w  .ja va 2s  .  c om
}

From source file:gcm_projeto_integracao.GCM.java

public void SendMSG(String registrationID, String mensagem) throws UnsupportedEncodingException {
    CloseableHttpClient client = HttpClients.createDefault();

    List<NameValuePair> list = new ArrayList<NameValuePair>();
    list.add(new BasicNameValuePair("registration_id", registrationID));
    list.add(new BasicNameValuePair("data.price", mensagem));

    HttpPost httpPost = new HttpPost(uRL);
    httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
    httpPost.setHeader("Authorization", "key=" + chave);

    httpPost.setEntity(new UrlEncodedFormEntity(list));
    try {//  w  w w. j av a  2 s.c  o  m
        client.execute(httpPost);
    } catch (IOException ex) {
        Logger.getLogger(GCM.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:br.com.estudogrupo.online.DicionarioOnline04.java

@Override
public void run() {
    HttpClient client = new DefaultHttpClient();
    HttpPost post = new HttpPost("http://www.md5online.org/");
    try {/*ww  w. j a  v a  2 s .  com*/
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
        nameValuePairs.add(new BasicNameValuePair("md5", getRecebe()));
        nameValuePairs.add(new BasicNameValuePair("search", "0"));
        nameValuePairs.add(new BasicNameValuePair("action", "decrypt"));
        nameValuePairs.add(new BasicNameValuePair("a", "82355607"));
        post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        HttpResponse response = client.execute(post);
        BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
        String line = "";
        while ((line = rd.readLine().trim()) != null) {
            if (line.startsWith("<span class=\"result\"")) {
                String key = line.substring(81, 100);
                System.out.println("Senha  : " + key.trim().replace("</b>", "").replace("</s>", "")
                        .replace("</span><br", "").replace(" /", ""));
            }

        }
    } catch (IOException e) {
        e.printStackTrace();

    } catch (NullPointerException e) {

    }

}

From source file:org.codeqinvest.web.IntegrationTestHelper.java

public static void addNewProfile(QualityProfile profile) throws IOException {
    doPostRequest(ADD_QUALITY_PROFILE_SITE,
            Arrays.<NameValuePair>asList(new BasicNameValuePair("name", profile.getName())));
}

From source file:com.peteydog7.mcstreamnotifier.twitch.SubscribeEvent.java

public static void checkExistingSubscribers() {

    String result = null;//  www.  j a va  2 s  .co  m
    List<String> latest = new ArrayList<String>();

    List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
    urlParameters.add(new BasicNameValuePair("direction", "DESC"));
    urlParameters.add(new BasicNameValuePair("limit", "50"));
    urlParameters.add(new BasicNameValuePair("offset", "0"));

    try {
        result = Http.sendApiGet(String.format(Twitch.FOLLOW_PATH, Config.Value.TWITCH_CHANNEL), urlParameters);
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (result == null) {
        return;
    }

    JSONObject jsonObject = new JSONObject(result);

    for (int i = 0; i < 50; i++) {
        String current = jsonObject.getJSONArray("follows").getJSONObject(i).getJSONObject("user")
                .getString("name");
        latest.add(current);
    }

    for (String current : latest) {

    }

    existingSubscribers.addAll(latest);

}

From source file:nz.co.jsrsolutions.tideservice.scraper.provider.EasyTideRegionSelectClickHttpPost.java

public EasyTideRegionSelectClickHttpPost(URI uri, String viewState, String eventValidation, String areaId,
        String region) {//  w  w  w.  j  a  v  a 2 s . c o  m

    super(uri, viewState);

    List<NameValuePair> nvps = new ArrayList<NameValuePair>();
    nvps.add(new BasicNameValuePair("__VIEWSTATE", viewState));
    nvps.add(new BasicNameValuePair("__EVENTVALIDATION", eventValidation));
    nvps.add(new BasicNameValuePair("__EVENTTARGET", ""));
    nvps.add(new BasicNameValuePair("__EVENTARGUMENT", ""));
    nvps.add(new BasicNameValuePair("__LASTFOCUS", ""));

    nvps.add(new BasicNameValuePair("PortSelectionAreas:ddlAreas", areaId));
    nvps.add(new BasicNameValuePair("PortSelectionAreas:ddlRegions", region));
    nvps.add(new BasicNameValuePair("PortSelectionAreas:butShowPorts:_ctl0.x", "51"));
    nvps.add(new BasicNameValuePair("PortSelectionAreas:butShowPorts:_ctl0.y", "22"));

    setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8));

}

From source file:nz.co.jsrsolutions.tideservice.scraper.provider.EasyTidePageLinkClickHttpPost.java

public EasyTidePageLinkClickHttpPost(URI uri, String viewState, String eventValidation, String areaId,
        String region, String controlId) {

    super(uri, viewState);

    List<NameValuePair> nvps = new ArrayList<NameValuePair>();
    nvps.add(new BasicNameValuePair("__VIEWSTATE", viewState));
    nvps.add(new BasicNameValuePair("__EVENTVALIDATION", eventValidation));
    nvps.add(new BasicNameValuePair("__EVENTTARGET", controlId));
    nvps.add(new BasicNameValuePair("__EVENTARGUMENT", ""));
    nvps.add(new BasicNameValuePair("__LASTFOCUS", ""));

    nvps.add(new BasicNameValuePair("PortSelectionAreas:ddlAreas", areaId));
    nvps.add(new BasicNameValuePair("PortSelectionAreas:ddlRegions", region));

    setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8));

}

From source file:nz.co.jsrsolutions.tideservice.scraper.provider.EasyTidePortLinkClickHttpPost.java

public EasyTidePortLinkClickHttpPost(URI uri, String viewState, String eventValidation, String areaId,
        String region, String controlId) {

    super(uri, viewState);

    List<NameValuePair> nvps = new ArrayList<NameValuePair>();
    nvps.add(new BasicNameValuePair("__VIEWSTATE", viewState));
    nvps.add(new BasicNameValuePair("__EVENTVALIDATION", eventValidation));
    nvps.add(new BasicNameValuePair("__EVENTTARGET", controlId));
    nvps.add(new BasicNameValuePair("__EVENTARGUMENT", ""));
    nvps.add(new BasicNameValuePair("__LASTFOCUS", ""));

    nvps.add(new BasicNameValuePair("PortSelectionAreas:ddlAreas", areaId));
    nvps.add(new BasicNameValuePair("PortSelectionAreas:ddlRegions", region));

    setEntity(new UrlEncodedFormEntity(nvps, Consts.UTF_8));

}

From source file:com.sourcey.materiallogindemo.MasterActivity.java

public int GetCountNotification(String user_id, String url) {
    PostData[] listData;//from   w  w w.ja va2s. com
    int count = 0;
    // Paste Parameters
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("user_id", user_id));
    try {
        JSONArray data = new JSONArray(getJSONUrl(url, params));
        String txtType = "";

        if (data.length() > 0) {
            PostData data_add = null;
            // listData = null;
            listData = new PostData[data.length()];
            for (int i = 0; i < data.length(); i++) {
                JSONObject c = data.getJSONObject(i);

                if ("CAR".equals(c.getString("type"))) {
                    txtType = "";
                } else if ("NOCAR".equals(c.getString("type"))) {
                    txtType = "";
                }

                data_add = new PostData();
                data_add.request_id = c.getString("request_id");
                data_add.postMapID = c.getString("map_id");
                data_add.m_user_id = c.getString("m_user_id");
                data_add.r_user_id = c.getString("r_user_id");
                data_add.type = c.getString("type");
                data_add.postName = "" + txtType + ": " + c.getString("firstname") + " "
                        + c.getString("lastname");
                data_add.postStart = ": " + c.getString("start");
                data_add.postEnd = ": " + c.getString("end");
                data_add.postPoint = ": " + c.getString("meeting_point");
                data_add.postTime = "-: " + c.getString("map_datetime") + " .";
                data_add.postLicensePlate = ": " + c.getString("license_plate");
                data_add.postThumbUrl = null;
                listData[i] = data_add;
            }
            count = listData.length;
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return count;
}

From source file:att.jaxrs.client.Tag.java

public static String addTag(Tag tag) {
    final long tag_id = getExistingRecord(tag.getTag_name());
    if (-1L != tag_id) {
        return "{response:{Tag: 'EXISTING_RECORD'},tag_id:" + tag_id + "}";
    }/*w  ww.  j  a  v  a2s.com*/
    List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
    urlParameters.add(new BasicNameValuePair("tag_name", tag.getTag_name()));

    HttpResponse result;
    String resultStr = "";

    try {

        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost post = new HttpPost(Constants.INSERT_TAG_RESOURCE);
        post.setEntity(new UrlEncodedFormEntity(urlParameters));
        result = httpClient.execute(post);
        System.out.println(Constants.RESPONSE_STATUS_CODE + result);
        resultStr = Util.getStringFromInputStream(result.getEntity().getContent());
        System.out.println(Constants.RESPONSE_BODY + resultStr);

    } catch (Exception e) {
        System.out.println(e.getMessage());

    }
    return resultStr;
}