use of org.apache.http.client.ClientProtocolException in project coinbase-bitmonet-sdk by coinbase.
the class HTTPUtils method makeHttpPostRequest.
public static HttpResponse makeHttpPostRequest(String path) {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(path);
try {
return httpclient.execute(httppost);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
use of org.apache.http.client.ClientProtocolException in project Trello-Android by chrisHoekstra.
the class TrelloService method getNotifications.
public ArrayList<NotificationVO> getNotifications() {
ArrayList<NotificationVO> result = null;
ArrayList<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
params.add(new BasicNameValuePair("key", PUBLIC_KEY));
params.add(new BasicNameValuePair("token", mToken));
HttpGet httpGet = new HttpGet(TRELLO_API_URL + "members/" + "me/" + "notifications?" + URLEncodedUtils.format(params, "UTF-8"));
HttpClient httpClient = getHttpClient();
try {
httpGet.setHeader("Accept", "application/json, text/javascript, */*; q=0.01");
httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, USER_AGENT_STRING);
HttpResponse response = httpClient.execute(httpGet, mContext);
if (response != null) {
result = mObjectMapper.readValue(mJsonFactory.createJsonParser(new InputStreamReader(response.getEntity().getContent(), "UTF-8")), new TypeReference<ArrayList<NotificationVO>>() {
});
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
use of org.apache.http.client.ClientProtocolException in project Trello-Android by chrisHoekstra.
the class TrelloService method addCard.
public Boolean addCard(String boardListId, String name) {
Boolean result = false;
ArrayList<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
params.add(new BasicNameValuePair("key", PUBLIC_KEY));
params.add(new BasicNameValuePair("token", mToken));
params.add(new BasicNameValuePair("name", name));
params.add(new BasicNameValuePair("idList", boardListId));
HttpPost httpPost = new HttpPost(TRELLO_API_URL + "cards?" + URLEncodedUtils.format(params, "UTF-8"));
HttpClient httpClient = getHttpClient();
try {
httpPost.setHeader("Accept", "application/json, text/javascript, */*; q=0.01");
httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, USER_AGENT_STRING);
HttpResponse response = httpClient.execute(httpPost, mContext);
if (response != null) {
result = true;
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
use of org.apache.http.client.ClientProtocolException in project UltimateAndroid by cymcsg.
the class HttpUtils_Deprecated method loadImageFromUrl.
public static byte[] loadImageFromUrl(String url) {
InputStream i = null;
byte[] filename = null;
try {
byte[] dbfilename = null;
DefaultHttpClient httpClient = new DefaultHttpClient();
String geturl = url;
HttpGet request = new HttpGet(geturl);
request.setHeader("referer", "http://pic.qingdaonews.com");
HttpResponse response = httpClient.execute(request);
i = response.getEntity().getContent();
ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
int ch;
while ((ch = i.read()) != -1) {
bytestream.write(ch);
}
filename = bytestream.toByteArray();
bytestream.close();
i.close();
return filename;
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return filename;
}
use of org.apache.http.client.ClientProtocolException in project Anki-Android by Ramblurr.
the class HttpUtility method postReport.
public static Boolean postReport(String url, List<NameValuePair> values) {
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
try {
httpPost.setEntity(new UrlEncodedFormEntity(values));
HttpResponse response = httpClient.execute(httpPost);
switch(response.getStatusLine().getStatusCode()) {
case 200:
Log.e(AnkiDroidApp.TAG, String.format("feedback report posted to %s", url));
return true;
default:
Log.e(AnkiDroidApp.TAG, String.format("feedback report posted to %s message", url));
Log.e(AnkiDroidApp.TAG, String.format("%d: %s", response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase()));
break;
}
} catch (ClientProtocolException ex) {
Log.e(AnkiDroidApp.TAG, ex.toString());
} catch (IOException ex) {
Log.e(AnkiDroidApp.TAG, ex.toString());
}
return false;
}
Aggregations