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:com.example.typetalk.request.message.MessageParameter.java

@Override
public List<NameValuePair> encode() {
    List<NameValuePair> params = new ArrayList<>();
    params.add(new BasicNameValuePair("message", message));
    if (replyTo != null) {
        params.add(new BasicNameValuePair("replyTo", replyTo.toString()));
    }/*from ww  w.  j a  v  a  2  s  .c  om*/
    if (fileKeys != null) {
        for (int i = 0; i < fileKeys.length; i++) {
            params.add(new BasicNameValuePair("fileKeys[" + i + "]", fileKeys[i]));
        }
    }
    if (talkIds != null) {
        for (int i = 0; i < talkIds.length; i++) {
            params.add(new BasicNameValuePair("talkIds[" + i + "]", talkIds[i].toString()));
        }
    }
    if (attachments != null) {
        for (int i = 0; i < attachments.length; i++) {
            params.add(new BasicNameValuePair("attachments[" + i + "].fileUrl", attachments[i].getFileUrl()));
            params.add(new BasicNameValuePair("attachments[" + i + "].fileName", attachments[i].getFileName()));
        }
    }
    return params;
}

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

public static String updateWebinar(Webinar webinar) {
    List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
    urlParameters.add(new BasicNameValuePair("content_id", webinar.getContent_id().toString()));
    urlParameters.add(new BasicNameValuePair("presenter", webinar.getPresenter()));

    String resultStr = "";

    try {//from  w  w  w .j av  a 2 s  . co  m

        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost post = new HttpPost(Constants.UPDATE_WEBINAR_RESOURCE);
        post.setEntity(new UrlEncodedFormEntity(urlParameters));
        HttpResponse 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;
}

From source file:com.phicomm.account.operator.GetMapOperation.java

@Override
public Bundle execute(Context context, Request request) {
    String ssession_id = null;/*from   w  w  w .  j  a  v a  2 s . com*/
    Bundle resultData = new Bundle();
    Cursor persionCursor = context.getContentResolver().query(Provider.PersonColumns.CONTENT_URI, null, null,
            null, null);
    if (persionCursor != null) {
        if (persionCursor.moveToFirst()) {
            ssession_id = persionCursor
                    .getString(persionCursor.getColumnIndex(Provider.PersonColumns.JSSESSIONID));
        }
        persionCursor.close();
    }

    String url = WSConfig.WS_GET_MAP_URL + ssession_id;
    NetworkConnection networkConnection1 = new NetworkConnection(context, url);
    ArrayList<BasicNameValuePair> parameterList = new ArrayList<BasicNameValuePair>();
    BasicNameValuePair value = new BasicNameValuePair("XML", "");
    parameterList.add(value);
    networkConnection1.setParameters(parameterList);
    try {
        ConnectionResult result = networkConnection1.execute();
        resultData.putString("result", result.body);
        Log.i("ss", "map________________________________result.body:" + result.body);
    } catch (ConnectionException e) {
        e.printStackTrace();
    }
    Log.i("ss", "_______________________________________OK");
    return resultData;
}

From source file:org.mule.module.http.functional.listener.HttpListenerParseRequestTestCase.java

private void sendUrlEncodedPost(String path, int port) throws IOException {
    Request.Post(getUrl(path, port)).bodyForm(new BasicNameValuePair("key", "value"))
            .connectTimeout(RECEIVE_TIMEOUT).socketTimeout(RECEIVE_TIMEOUT).execute();
}

From source file:securitytools.veracode.http.request.GetApplicationInfoRequest.java

public GetApplicationInfoRequest(String applicationId) {
    super("/api/4.0/getappinfo.do");

    if (ValidationUtils.isNullOrEmpty(applicationId)) {
        throw new IllegalArgumentException("\"applicationId\" argument cannot be null or empty.");
    }/*from  w  ww  . ja  va  2 s  .c o  m*/

    List<NameValuePair> formparams = new ArrayList<NameValuePair>();
    formparams.add(new BasicNameValuePair("app_id", applicationId));

    setEntity(new UrlEncodedFormEntity(formparams, Consts.UTF_8));
}

From source file:Main.java

/**
 * Adds all parameters within the Scanner to the list of <code>parameters</code>.
 * For example,a scanner containing the string <code>a=1&b=2&c=3</code> would
 * add the {@link org.apache.http.NameValuePair NameValuePairs} a=1, b=2, and c=3 to the
 * list of parameters.// ww  w.  ja v  a2s.co  m
 *
 * @param parameters List to add parameters to.
 * @param scanner    Input that contains the parameters to parse.
 */
public static void parse(final List<NameValuePair> parameters, final Scanner scanner) {
    scanner.useDelimiter(PARAMETER_SEPARATOR);
    while (scanner.hasNext()) {
        String name = null;
        String value = null;
        String token = scanner.next();
        int i = token.indexOf(NAME_VALUE_SEPARATOR);
        if (i != -1) {
            name = token.substring(0, i).trim();
            value = token.substring(i + 1).trim();
        } else {
            name = token.trim();
        }
        parameters.add(new BasicNameValuePair(name, value));
    }
}

From source file:com.subgraph.vega.impl.scanner.forms.FormHints.java

private void add(String k, String v) {
    hintList.add(new BasicNameValuePair(k, v));
}

From source file:org.kei.android.phone.mangastore.http.HttpTaskFetch.java

@Override
protected JSONArray doInBackground(final String... params) {
    JSONArray result = null;//ww w  . j  ava2 s  .c  o m
    BufferedReader reader = null;
    try {
        final HttpClient client = new DefaultHttpClient();
        final HttpPost httpPost = new HttpPost(params[0]);
        final List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(new BasicNameValuePair("android_name", params[1]));
        nameValuePairs.add(new BasicNameValuePair("android_password", params[2]));
        httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        final HttpResponse response = client.execute(httpPost);
        final StatusLine statusLine = response.getStatusLine();
        final int code = statusLine.getStatusCode();
        if (code == 200) {
            final StringBuilder sb = new StringBuilder();
            final HttpEntity entity = response.getEntity();
            final InputStream content = entity.getContent();
            reader = new BufferedReader(new InputStreamReader(content));
            String line;
            while ((line = reader.readLine()) != null)
                sb.append(line);
            result = new JSONArray(sb.toString());
        } else {
            throw new IOException(
                    "The server has responded an error " + code + " (" + statusLine.getReasonPhrase() + ")");
        }
    } catch (final Exception e) {
        t.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                t.onTaskError(e);
            }
        });
    } finally {
        if (reader != null) {
            try {
                reader.close();
            } catch (final IOException e) {
            }
        }
    }
    return result;
}

From source file:com.ratebeer.android.api.command.SearchUsersCommand.java

@Override
protected String makeRequest(ApiConnection apiConnection) throws ApiException {
    return apiConnection.post("http://www.ratebeer.com/usersearch.php",
            Arrays.asList(new BasicNameValuePair("UserName", getNormalizedQuery())));
}