本文整理汇总了Java中cz.msebera.android.httpclient.client.HttpClient.execute方法的典型用法代码示例。如果您正苦于以下问题:Java HttpClient.execute方法的具体用法?Java HttpClient.execute怎么用?Java HttpClient.execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cz.msebera.android.httpclient.client.HttpClient
的用法示例。
在下文中一共展示了HttpClient.execute方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import cz.msebera.android.httpclient.client.HttpClient; //导入方法依赖的package包/类
public static Hostplace get(String ip) throws Exception {
HttpGet httppost = new HttpGet(Geocode.url + "/" + ip);
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(httppost);
// StatusLine stat = response.getStatusLine();
int status = response.getStatusLine().getStatusCode();
if (status == 200) {
HttpEntity entity = response.getEntity();
String data = EntityUtils.toString(entity);
JSONObject json = new JSONObject(data);
if (json.getString("status").equals("fail"))
throw new Exception();
Hostplace hostplace = Hostplace.getJson(json);
return hostplace;
}
throw new Exception();
}
示例2: getBlock
import cz.msebera.android.httpclient.client.HttpClient; //导入方法依赖的package包/类
public static Block getBlock(String blockhash) throws Exception {
HttpGet httppost = new HttpGet(Insight.url + "/block/" + blockhash);
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(httppost);
// StatusLine stat = response.getStatusLine();
int status = response.getStatusLine().getStatusCode();
if (status == 200) {
HttpEntity entity = response.getEntity();
String data = EntityUtils.toString(entity);
JSONObject json = new JSONObject(data);
Block block = Block.getJson(json);
return block;
}
throw new Exception();
}
示例3: getBlockHash
import cz.msebera.android.httpclient.client.HttpClient; //导入方法依赖的package包/类
public static String getBlockHash(String height) throws Exception {
HttpGet httppost = new HttpGet(Insight.url + "/block-index/" + height);
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(httppost);
// StatusLine stat = response.getStatusLine();
int status = response.getStatusLine().getStatusCode();
if (status == 200) {
HttpEntity entity = response.getEntity();
String data = EntityUtils.toString(entity);
JSONObject json = new JSONObject(data);
String hash = json.getString("blockHash");
return hash;
}
throw new Exception();
}
示例4: getTx
import cz.msebera.android.httpclient.client.HttpClient; //导入方法依赖的package包/类
public static Tx getTx(String hash) throws Exception {
HttpGet httppost = new HttpGet(Insight.url + "/tx/" + hash);
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(httppost);
// StatusLine stat = response.getStatusLine();
int status = response.getStatusLine().getStatusCode();
if (status == 200) {
HttpEntity entity = response.getEntity();
String data = EntityUtils.toString(entity);
JSONObject json = new JSONObject(data);
Tx tx = Tx.getJson(json);
return tx;
}
throw new Exception();
}
示例5: getHtmlConsolePage
import cz.msebera.android.httpclient.client.HttpClient; //导入方法依赖的package包/类
private static String getHtmlConsolePage(String dev_acc, CookieStore cookieStore) throws IOException, NetworkException {
HttpGet get = new HttpGet(Utils.DEVELOPER_CONSOLE_URL + "?dev_acc=" + dev_acc);
HttpClient client = HttpClientBuilder.create().setDefaultCookieStore(cookieStore).build();
HttpResponse resp = client.execute(get);
StatusLine sl = resp.getStatusLine();
if (sl.getStatusCode() != 200) throw new NetworkException(sl);
return EntityUtils.toString(resp.getEntity(), Charset.forName("UTF-8"));
}
示例6: doInBackground
import cz.msebera.android.httpclient.client.HttpClient; //导入方法依赖的package包/类
@Override
protected Void doInBackground(String... message) {
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.instruman.it/assets/feedback/update.php");
try {
//add data
List<NameValuePair> nameValuePairs = new ArrayList<>(1);
nameValuePairs.add(new BasicNameValuePair("stars", message[0]));
nameValuePairs.add(new BasicNameValuePair("message", message[1]));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
//execute http post
HttpResponse response = httpclient.execute(httppost);
} catch (Exception e) {
}
return null;
}