当前位置: 首页>>代码示例>>Java>>正文


Java HttpClient.execute方法代码示例

本文整理汇总了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();
}
 
开发者ID:lvaccaro,项目名称:BitcoinBlockExplorer,代码行数:22,代码来源:Geocode.java

示例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();
}
 
开发者ID:lvaccaro,项目名称:BitcoinBlockExplorer,代码行数:19,代码来源:Insight.java

示例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();
}
 
开发者ID:lvaccaro,项目名称:BitcoinBlockExplorer,代码行数:19,代码来源:Insight.java

示例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();
}
 
开发者ID:lvaccaro,项目名称:BitcoinBlockExplorer,代码行数:19,代码来源:Insight.java

示例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"));
}
 
开发者ID:devgianlu,项目名称:PlayConsoleAndroidAPI,代码行数:12,代码来源:PlayConsoleAuthenticator.java

示例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;
}
 
开发者ID:paolo-optc,项目名称:optc-mobile-db,代码行数:21,代码来源:FeedbackDialogFragment.java


注:本文中的cz.msebera.android.httpclient.client.HttpClient.execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。