Search in sources :

Example 56 with BasicNameValuePair

use of org.apache.http.message.BasicNameValuePair in project 12306-hunter by xautlx.

the class HttpClientService method queryTrain.

public List<TrainQueryInfo> queryTrain(TicketData ticketData, UserData userData, String trainDate) {
    HttpClient httpClient = buildHttpClient();
    try {
        List<NameValuePair> parameters = new ArrayList<NameValuePair>();
        parameters.add(new BasicNameValuePair(QUERY_TRAIN_DATE, trainDate));
        parameters.add(new BasicNameValuePair(QUERY_FROM_STATION_TELECODE, ticketData.getTrainFromCode()));
        parameters.add(new BasicNameValuePair(QUERY_TO_STATION_TELECODE, ticketData.getTrainToCode()));
        parameters.add(new BasicNameValuePair(QUERY_TRAIN_NO, ""));
        parameters.add(new BasicNameValuePair(QUERY_TRAINPASSTYPE, "QB"));
        parameters.add(new BasicNameValuePair(QUERY_TRAINCLASS, "QB#D#Z#T#K#QT#"));
        parameters.add(new BasicNameValuePair(QUERY_INCLUDESTUDENT, "00"));
        parameters.add(new BasicNameValuePair(QUERY_SEATTYPEANDNUM, ""));
        parameters.add(new BasicNameValuePair(QUERY_START_TIME_STR, "00:00--24:00"));
        String response = getHttpRequestAsString(httpClient, GET_URL_QUERYTICKET, parameters, userData.getCookieData());
        return TicketUtil.parserQueryInfo(response);
    } finally {
        httpClient.getConnectionManager().shutdown();
    }
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) HttpClient(org.apache.http.client.HttpClient) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) ArrayList(java.util.ArrayList)

Example 57 with BasicNameValuePair

use of org.apache.http.message.BasicNameValuePair in project api-snippets by TwilioDevEd.

the class TwilioTest method main.

public static void main(String[] args) throws TwilioRestException {
    TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
    // Build the parameters
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("To", "+15558675309"));
    params.add(new BasicNameValuePair("From", "+15017250604"));
    params.add(new BasicNameValuePair("Body", "This is the ship that made the Kessel Run in fourteen parsecs?"));
    MessageFactory messageFactory = client.getAccount().getMessageFactory();
    Message message = messageFactory.create(params);
    System.out.println(message.getSid());
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) ArrayList(java.util.ArrayList)

Example 58 with BasicNameValuePair

use of org.apache.http.message.BasicNameValuePair in project tdi-studio-se by Talend.

the class paloconnection method logout.

// Logouts the current palo User
public void logout() throws paloexception {
    List<NameValuePair> qparams = new ArrayList<NameValuePair>();
    qparams.add(new BasicNameValuePair("sid", this.strToken));
    try {
        HttpEntity entity = sendToServer(qparams, "/server/logout");
        CSVReader csv = new CSVReader(entity.getContent(), ';', "UTF-8");
        // CsvReader csv = new CsvReader(sendToServer(qparams, "/server/logout").getContent(),
        // Charset.defaultCharset());
        csv.setQuoteChar('"');
        csv.readNext();
        csv.close();
        entity.consumeContent();
    // paloHttpClient.getConnectionManager().shutdown();
    } catch (Exception e) {
        throw new paloexception(e.getMessage());
    }
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) HttpEntity(org.apache.http.HttpEntity) CSVReader(com.talend.csv.CSVReader) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) ArrayList(java.util.ArrayList)

Example 59 with BasicNameValuePair

use of org.apache.http.message.BasicNameValuePair in project tdi-studio-se by Talend.

the class paloconnection method getRulefunctions.

public String getRulefunctions() throws paloexception {
    List<NameValuePair> qparams = new ArrayList<NameValuePair>();
    qparams.add(new BasicNameValuePair("sid", getPaloToken()));
    try {
        StringBuilder sb = new StringBuilder();
        HttpEntity entity = sendToServer(qparams, "/rule/functions");
        CSVReader csv = new CSVReader(entity.getContent(), ';', "UTF-8");
        csv.setQuoteChar('"');
        while (csv.readNext()) {
            sb.append(csv.get(0));
        }
        csv.close();
        entity.consumeContent();
        return sb.toString();
    } catch (Exception e) {
        throw new paloexception(e.getMessage());
    }
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) HttpEntity(org.apache.http.HttpEntity) CSVReader(com.talend.csv.CSVReader) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) ArrayList(java.util.ArrayList)

Example 60 with BasicNameValuePair

use of org.apache.http.message.BasicNameValuePair in project tdi-studio-se by Talend.

the class paloconnection method load.

// Load the Server
public void load() throws paloexception {
    List<NameValuePair> qparams = new ArrayList<NameValuePair>();
    qparams.add(new BasicNameValuePair("sid", this.strToken));
    sendToServerSingleRC(qparams, "/server/load");
}
Also used : BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) ArrayList(java.util.ArrayList)

Aggregations

BasicNameValuePair (org.apache.http.message.BasicNameValuePair)289 NameValuePair (org.apache.http.NameValuePair)199 ArrayList (java.util.ArrayList)187 UrlEncodedFormEntity (org.apache.http.client.entity.UrlEncodedFormEntity)101 HttpPost (org.apache.http.client.methods.HttpPost)87 HttpResponse (org.apache.http.HttpResponse)77 HttpEntity (org.apache.http.HttpEntity)58 IOException (java.io.IOException)55 DefaultHttpClient (org.apache.http.impl.client.DefaultHttpClient)33 Test (org.junit.Test)32 HttpGet (org.apache.http.client.methods.HttpGet)29 ClientProtocolException (org.apache.http.client.ClientProtocolException)28 CSVReader (com.talend.csv.CSVReader)27 HttpClient (org.apache.http.client.HttpClient)25 UnsupportedEncodingException (java.io.UnsupportedEncodingException)23 HashMap (java.util.HashMap)20 JSONObject (org.json.JSONObject)20 Map (java.util.Map)19 URI (java.net.URI)16 WebserviceInvocation (com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation)15