#Java - Code Snippets for '#HttpClient' - 3 code snippet(s) found |
|
Sample 1. Calling an Api using HttpClient and HttpPost | |
|
String url = "https://www.googleapis.com/blogger/v3/blogs/xxxxxxxxxx/posts?clientId=xxxxxxxx&clientSecret=xxxxxxxx";
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(url);
// add header
post.setHeader("Authorization", authorization_key);
post.setHeader("Content-type","application/json");
post.setEntity(new StringEntity(buildJson(title,content,label)));
HttpResponse response = client.execute(post);
|
|
Like Feedback HttpClient HttpPost Calling api |
|
|
Sample 2. Code Sample / Example / Snippet of org.apache.commons.httpclient.HttpMethod | |
|
private static int httpNotification(String uri) throws IOException {
URI url = new URI(uri, false);
HttpClient m_client = new HttpClient();
HttpMethod method = new GetMethod(url.getEscapedURI());
method.setRequestHeader("Accept", "*/*");
return m_client.executeMethod(method);
}
|
|
Like Feedback org.apache.commons.httpclient.HttpMethod |
|
|
Sample 3. Code Sample / Example / Snippet of org.apache.commons.httpclient.HttpClient | |
|
private static int httpNotification(String uri) throws IOException {
URI url = new URI(uri, false);
HttpClient m_client = new HttpClient();
HttpMethod method = new GetMethod(url.getEscapedURI());
method.setRequestHeader("Accept", "*/*");
return m_client.executeMethod(method);
}
|
|
Like Feedback org.apache.commons.httpclient.HttpClient |
|
|