• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java UrlEncodedFormEntity类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity的典型用法代码示例。如果您正苦于以下问题:Java UrlEncodedFormEntity类的具体用法?Java UrlEncodedFormEntity怎么用?Java UrlEncodedFormEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UrlEncodedFormEntity类属于cz.msebera.android.httpclient.client.entity包,在下文中一共展示了UrlEncodedFormEntity类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: putWikiPage

import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity; //导入依赖的package包/类
/**
 * Replaces an entire wiki page
 *
 * @param httpclient an active HTTP session
 * @param pagename   the name of the wiki page
 * @param content    the new content of the wiki page to be submitted
 * @param formfields a hashmap with the fields needed (besides pagename and content; those will be filled in this method)
 * @throws WikiException problem with the wiki, translate the ID
 * @throws Exception     anything else happened, use getMessage
 */
public static void putWikiPage(@NonNull CloseableHttpClient httpclient,
                               @NonNull String pagename, String content,
                               @NonNull HashMap<String, String> formfields) throws Exception {
    // If there's no edit token in the hash map, we can't do anything.
    if(!formfields.containsKey("token")) {
        throw new WikiException(R.string.wiki_error_protected);
    }

    HttpPost httppost = new HttpPost(WIKI_API_URL);

    ArrayList<NameValuePair> nvps = new ArrayList<>();
    nvps.add(new BasicNameValuePair("action", "edit"));
    nvps.add(new BasicNameValuePair("title", pagename));
    nvps.add(new BasicNameValuePair("text", content));
    nvps.add(new BasicNameValuePair("format", "xml"));
    for(String s : formfields.keySet()) {
        nvps.add(new BasicNameValuePair(s, formfields.get(s)));
    }

    httppost.setEntity(new UrlEncodedFormEntity(nvps, "utf-8"));

    getWikiResponse(httpclient, httppost);

    // And really, that's it.  We're done!
}
 
开发者ID:CaptainSpam,项目名称:geohashdroid,代码行数:36,代码来源:WikiUtils.java


示例2: deletePost

import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity; //导入依赖的package包/类
@Override
public String deletePost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = getUsingUrl() + "cgi/delete";
    
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("board", model.boardName));
    pairs.add(new BasicNameValuePair("delete_" + model.postNumber, model.postNumber));
    pairs.add(new BasicNameValuePair("task", "delete"));
    pairs.add(new BasicNameValuePair("password", model.password));
    
    HttpRequestModel request = HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setNoRedirect(true).build();
    HttpResponseModel response = null;
    try {
        response = HttpStreamer.getInstance().getFromUrl(url, request, httpClient, null, task);
        if (response.statusCode == 302) {
            return null;
        }
        throw new Exception(response.statusCode + " - " + response.statusReason);
    } finally {
        if (response != null) response.release();
    }
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:23,代码来源:DvachnetModule.java


示例3: checkCaptcha

import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity; //导入依赖的package包/类
private void checkCaptcha(String answer, CancellableTask task) throws Exception {
    try {
        if (torCaptchaCookie == null) throw new Exception("Invalid captcha");
        String url = getUsingUrl() + "dnsbls_bypass.php";
        List<NameValuePair> pairs = new ArrayList<NameValuePair>();
        pairs.add(new BasicNameValuePair("captcha_text", answer));
        pairs.add(new BasicNameValuePair("captcha_cookie", torCaptchaCookie));
        HttpRequestModel rqModel = HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setTimeout(30000).build();
        String response = HttpStreamer.getInstance().getStringFromUrl(url, rqModel, httpClient, null, task, true);
        if (response.contains("Error") && !response.contains("Success")) throw new HttpWrongStatusCodeException(400, "400");
        needTorCaptcha = false;
    } catch (HttpWrongStatusCodeException e) {
        if (task != null && task.isCancelled()) throw new InterruptedException("interrupted");
        if (e.getStatusCode() == 400) throw new Exception("You failed the CAPTCHA");
        throw e;
    }
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:18,代码来源:InfinityModule.java


示例4: createFormEntity

import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity; //导入依赖的package包/类
private HttpEntity createFormEntity() {
    try {
        return new UrlEncodedFormEntity(getParamsList(), contentEncoding);
    } catch (UnsupportedEncodingException e) {
        AsyncHttpClient.log.e(LOG_TAG, "createFormEntity failed", e);
        return null; // Can happen, if the 'contentEncoding' won't be HTTP.UTF_8
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:RequestParams.java


示例5: doInBackground

import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity; //导入依赖的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


示例6: deletePost

import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity; //导入依赖的package包/类
@Override
public String deletePost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = getUsingUrl() + "post.php";
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("board", model.boardName));
    pairs.add(new BasicNameValuePair("delete_" + model.postNumber, "on"));
    if (model.onlyFiles) pairs.add(new BasicNameValuePair("file", "on"));
    pairs.add(new BasicNameValuePair("password", model.password));
    pairs.add(new BasicNameValuePair("delete", getDeleteFormValue(model)));
    pairs.add(new BasicNameValuePair("reason", ""));
    
    UrlPageModel refererPage = new UrlPageModel();
    refererPage.type = UrlPageModel.TYPE_THREADPAGE;
    refererPage.chanName = getChanName();
    refererPage.boardName = model.boardName;
    refererPage.threadNumber = model.threadNumber;
    Header[] customHeaders = new Header[] { new BasicHeader(HttpHeaders.REFERER, buildUrl(refererPage)) };
    HttpRequestModel rqModel = HttpRequestModel.builder().
            setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setCustomHeaders(customHeaders).setNoRedirect(true).build();
    HttpResponseModel response = null;
    try {
        response = HttpStreamer.getInstance().getFromUrl(url, rqModel, httpClient, listener, task);
        if (response.statusCode == 200 || response.statusCode == 400 || response.statusCode == 303) {
            ByteArrayOutputStream output = new ByteArrayOutputStream(1024);
            IOUtils.copyStream(response.stream, output);
            String htmlResponse = output.toString("UTF-8");
            Matcher errorMatcher = ERROR_PATTERN.matcher(htmlResponse);
            if (errorMatcher.find()) throw new Exception(errorMatcher.group(1));
            return null;
        }
        throw new Exception(response.statusCode + " - " + response.statusReason);
    } finally {
        if (response != null) response.release();
    }
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:36,代码来源:AbstractVichanModule.java


示例7: reportPost

import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity; //导入依赖的package包/类
@Override
public String reportPost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = getUsingUrl() + "post.php";
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("board", model.boardName));
    pairs.add(new BasicNameValuePair("delete_" + model.postNumber, "on"));
    pairs.add(new BasicNameValuePair("password", ""));
    pairs.add(new BasicNameValuePair("reason", model.reportReason));
    pairs.add(new BasicNameValuePair("report", getReportFormValue(model)));
    
    UrlPageModel refererPage = new UrlPageModel();
    refererPage.type = UrlPageModel.TYPE_THREADPAGE;
    refererPage.chanName = getChanName();
    refererPage.boardName = model.boardName;
    refererPage.threadNumber = model.threadNumber;
    Header[] customHeaders = new Header[] { new BasicHeader(HttpHeaders.REFERER, buildUrl(refererPage)) };
    HttpRequestModel rqModel = HttpRequestModel.builder().
            setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setCustomHeaders(customHeaders).setNoRedirect(true).build();
    HttpResponseModel response = null;
    try {
        response = HttpStreamer.getInstance().getFromUrl(url, rqModel, httpClient, listener, task);
        if (response.statusCode == 200 || response.statusCode == 400 || response.statusCode == 303) {
            ByteArrayOutputStream output = new ByteArrayOutputStream(1024);
            IOUtils.copyStream(response.stream, output);
            String htmlResponse = output.toString("UTF-8");
            Matcher errorMatcher = ERROR_PATTERN.matcher(htmlResponse);
            if (errorMatcher.find()) throw new Exception(errorMatcher.group(1));
            return null;
        }
        throw new Exception(response.statusCode + " - " + response.statusReason);
    } finally {
        if (response != null) response.release();
    }
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:35,代码来源:AbstractVichanModule.java


示例8: deletePost

import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity; //导入依赖的package包/类
@Override
public String deletePost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = getBoardScriptUrl(model);
    List<? extends NameValuePair> pairs = getDeleteFormAllValues(model);
    HttpRequestModel request = HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setNoRedirect(true).build();
    String result = HttpStreamer.getInstance().getStringFromUrl(url, request, httpClient, listener, task, false);
    checkDeletePostResult(model, result);
    return null;
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:10,代码来源:AbstractKusabaModule.java


示例9: reportPost

import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity; //导入依赖的package包/类
@Override
public String reportPost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = getBoardScriptUrl(model);
    List<? extends NameValuePair> pairs = getReportFormAllValues(model);
    HttpRequestModel request = HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setNoRedirect(true).build();
    String result = HttpStreamer.getInstance().getStringFromUrl(url, request, httpClient, listener, task, false);
    checkReportPostResult(model, result);
    return null;
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:10,代码来源:AbstractKusabaModule.java


示例10: deletePost

import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity; //导入依赖的package包/类
@Override
public String deletePost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = getDomainUrl() + model.boardName + "/delete";
    String threadAPIUrl = getDomainUrl() + "api/thread/" + model.boardName + "/" + model.threadNumber + ".json";
    String threadId = Long.toString(downloadJSONObject(threadAPIUrl, false, null, task).getLong("thread_id"));
    
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair(model.postNumber, threadId));
    pairs.add(new BasicNameValuePair("task", "delete"));
    pairs.add(new BasicNameValuePair("password", model.password));
    
    HttpRequestModel request = HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setNoRedirect(true).build();
    HttpResponseModel response = null;
    try {
        response = HttpStreamer.getInstance().getFromUrl(url, request, httpClient, null, task);
        if (response.statusCode == 200) {
            ByteArrayOutputStream output = new ByteArrayOutputStream(1024);
            IOUtils.copyStream(response.stream, output);
            String htmlResponse = output.toString("UTF-8");
            Matcher errorMatcher = Pattern.compile("<center><h2>([^<]*)<").matcher(htmlResponse);
            if (errorMatcher.find()) throw new Exception(errorMatcher.group(1));
        }
    } finally {
        if (response != null) response.release();
        saveHanabiraCookie();
    }
    return null;
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:29,代码来源:DobroModule.java


示例11: deletePost

import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity; //导入依赖的package包/类
@Override
public String deletePost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = getUsingUrl() + model.boardName + "/wakaba.pl";
    
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("delete", model.postNumber));
    pairs.add(new BasicNameValuePair("task", "delete"));
    if (model.onlyFiles) pairs.add(new BasicNameValuePair("fileonly", "on"));
    pairs.add(new BasicNameValuePair("password", model.password));
    
    HttpRequestModel request = HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setNoRedirect(true).build();
    HttpResponseModel response = null;
    try {
        response = HttpStreamer.getInstance().getFromUrl(url, request, httpClient, null, task);
        if (response.statusCode == 200) {
            ByteArrayOutputStream output = new ByteArrayOutputStream(1024);
            IOUtils.copyStream(response.stream, output);
            String htmlResponse = output.toString("UTF-8");
            if (!htmlResponse.contains("<blockquote")) {
                int start = htmlResponse.indexOf("<h1 style=\"text-align: center\">");
                if (start != -1) {
                    int end = htmlResponse.indexOf("<br /><br />", start + 31);
                    if (end != -1) {
                        throw new Exception(htmlResponse.substring(start + 31, end).trim());
                    }
                }
            }
        }
    } finally {
        if (response != null) response.release();
    }
    return null;
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:34,代码来源:NowereModule.java


示例12: deletePost

import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity; //导入依赖的package包/类
@Override
public String deletePost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = CHAN410_URL + "board.php";
    
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("board", model.boardName));
    pairs.add(new BasicNameValuePair("delete[]", model.postNumber));
    if (model.onlyFiles) pairs.add(new BasicNameValuePair("fileonly", "on"));
    pairs.add(new BasicNameValuePair("postpassword", model.password));
    pairs.add(new BasicNameValuePair("deletepost", "Удалить"));
    
    HttpRequestModel request = HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setNoRedirect(true).build();
    String result = HttpStreamer.getInstance().getStringFromUrl(url, request, httpClient, listener, task, false);
    if (result.contains("Неверный пароль")) throw new Exception("Неверный пароль");
    return null;
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:17,代码来源:Chan410Module.java


示例13: reportPost

import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity; //导入依赖的package包/类
@Override
public String reportPost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = CHAN410_URL + "board.php";
    
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("board", model.boardName));
    pairs.add(new BasicNameValuePair("delete[]", model.postNumber));
    pairs.add(new BasicNameValuePair("reportpost", "Пожаловаться"));
    
    HttpRequestModel request = HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setNoRedirect(true).build();
    String result = HttpStreamer.getInstance().getStringFromUrl(url, request, httpClient, listener, task, false);
    if (result.contains("Post successfully reported")) return null;
    throw new Exception(result);
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:15,代码来源:Chan410Module.java


示例14: deletePost

import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity; //导入依赖的package包/类
@Override
public String deletePost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = IICHAN_URL + "cgi-bin/wakaba.pl/" + model.boardName + "/";
    
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("delete", model.postNumber));
    pairs.add(new BasicNameValuePair("task", "delete"));
    if (model.onlyFiles) pairs.add(new BasicNameValuePair("fileonly", "on"));
    pairs.add(new BasicNameValuePair("password", model.password));
    
    HttpRequestModel request = HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setNoRedirect(true).build();
    HttpResponseModel response = null;
    try {
        response = HttpStreamer.getInstance().getFromUrl(url, request, httpClient, null, task);
        if (response.statusCode == 200) {
            ByteArrayOutputStream output = new ByteArrayOutputStream(1024);
            IOUtils.copyStream(response.stream, output);
            String htmlResponse = output.toString("UTF-8");
            if (!htmlResponse.contains("<blockquote")) {
                int start = htmlResponse.indexOf("<h1 style=\"text-align: center\">");
                if (start != -1) {
                    int end = htmlResponse.indexOf("<br /><br />", start + 31);
                    if (end != -1) {
                        throw new Exception(htmlResponse.substring(start + 31, end).trim());
                    }
                }
            }
        }
    } finally {
        if (response != null) response.release();
    }
    return null;
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:34,代码来源:CirnoModule.java


示例15: deletePost

import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity; //导入依赖的package包/类
@Override
public String deletePost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = getUsingUrl() + model.boardName + "/wakaba.pl";
    
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("delete", model.postNumber));
    pairs.add(new BasicNameValuePair("parent", model.threadNumber));
    pairs.add(new BasicNameValuePair("task", "delete"));
    if (model.onlyFiles) pairs.add(new BasicNameValuePair("fileonly", "on"));
    pairs.add(new BasicNameValuePair("password", model.password));
    
    HttpRequestModel request = HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setNoRedirect(true).build();
    HttpResponseModel response = null;
    try {
        response = HttpStreamer.getInstance().getFromUrl(url, request, httpClient, null, task);
        if (response.statusCode == 200) {
            ByteArrayOutputStream output = new ByteArrayOutputStream(1024);
            IOUtils.copyStream(response.stream, output);
            String htmlResponse = output.toString("UTF-8");
            if (!htmlResponse.contains("<blockquote")) {
                int start = htmlResponse.indexOf("<h1 style='text-align: center'>");
                if (start != -1) {
                    int end = htmlResponse.indexOf("<br><br>", start + 31);
                    if (end != -1) {
                        throw new Exception(htmlResponse.substring(start + 31, end).trim());
                    }
                }
            }
        }
    } finally {
        if (response != null) response.release();
    }
    return null;
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:35,代码来源:InachModule.java


示例16: deletePost

import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity; //导入依赖的package包/类
@Override
public String deletePost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = getUsingUrl() + model.boardName + "/delete";
    
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("posts[]", model.postNumber));
    pairs.add(new BasicNameValuePair("password", model.password));
    pairs.add(new BasicNameValuePair("deletepost", "Удалить"));
    
    HttpRequestModel request = HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setNoRedirect(true).build();
    String result = HttpStreamer.getInstance().getStringFromUrl(url, request, httpClient, listener, task, false);
    if (result.contains("Неверный пароль")) throw new Exception("Неверный пароль");
    return null;
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:15,代码来源:DvachModule.java


示例17: deletePost

import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity; //导入依赖的package包/类
@Override
public String deletePost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = getUsingUrl() + model.boardName + "/wakaba.pl";
    
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("delete", model.postNumber));
    pairs.add(new BasicNameValuePair("task", "delete"));
    if (model.onlyFiles) pairs.add(new BasicNameValuePair("fileonly", "on"));
    pairs.add(new BasicNameValuePair("password", model.password));
    
    HttpRequestModel request = HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setNoRedirect(true).build();
    HttpResponseModel response = null;
    try {
        response = HttpStreamer.getInstance().getFromUrl(url, request, httpClient, null, task);
        if (response.statusCode == 200) {
            ByteArrayOutputStream output = new ByteArrayOutputStream(1024);
            IOUtils.copyStream(response.stream, output);
            String htmlResponse = output.toString("UTF-8");
            if (!htmlResponse.contains("<blockquote")) {
                int start = htmlResponse.indexOf("<h1 style=\"text-align: center\">");
                if (start != -1) {
                    int end = htmlResponse.indexOf("<br /><br />", start + 31);
                    if (end != -1) {
                        throw new Exception(htmlResponse.substring(start + 31, end).trim());
                    }
                }
            }
        } else if (response.statusCode == 403) {
            throw new Exception("Доступ заборонено");
        }
    } finally {
        if (response != null) response.release();
    }
    return null;
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:36,代码来源:UchanModule.java


示例18: sendPost

import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity; //导入依赖的package包/类
@Override
public String sendPost(SendPostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    if (model.comment.length() > 500) throw new Exception("Максимальная длина сообщения - 500 символов");
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("cid", cid));
    pairs.add(new BasicNameValuePair("left", Integer.toString(500 - model.comment.length())));
    pairs.add(new BasicNameValuePair("msg", model.comment));
    pairs.add(new BasicNameValuePair("check", model.captchaAnswer));
    
    HttpRequestModel request =
            HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setCustomHeaders(HTTP_HEADER_FEEDBACK).build();
    HttpResponseModel response = null;
    try {
        response = HttpStreamer.getInstance().getFromUrl("http://" + DOMAIN + "/feedback", request, httpClient, null, task);
        if (response.statusCode == 200) {
            ByteArrayOutputStream output = new ByteArrayOutputStream(1024);
            IOUtils.copyStream(response.stream, output);
            String htmlResponse = output.toString("UTF-8");
            if (htmlResponse.contains("window.close,10000")) return "http://" + DOMAIN + "/#" + getCurrentThreadNumber();
            if (htmlResponse.contains("Неверный код подтверждения")) throw new Exception("Неверный код подтверждения");
            throw new Exception("Ошибка отправки");
        } else {
            throw new Exception(response.statusCode + " - " + response.statusReason);
        }
    } finally {
        if (response != null) response.release();
    }
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:29,代码来源:AnonFmModule.java


示例19: deletePost

import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity; //导入依赖的package包/类
@Override
public String deletePost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception {
    String url = getUsingUrl() + model.boardName + "/wakaba.pl";
    
    List<NameValuePair> pairs = new ArrayList<NameValuePair>();
    pairs.add(new BasicNameValuePair("delete", model.postNumber));
    pairs.add(new BasicNameValuePair("task", "delete"));
    if (model.onlyFiles) pairs.add(new BasicNameValuePair("fileonly", "on"));
    pairs.add(new BasicNameValuePair("password", model.password));
    
    HttpRequestModel request = HttpRequestModel.builder().setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).setNoRedirect(true).build();
    HttpResponseModel response = null;
    try {
        response = HttpStreamer.getInstance().getFromUrl(url, request, httpClient, null, task);
        if (response.statusCode == 200) {
            ByteArrayOutputStream output = new ByteArrayOutputStream(1024);
            IOUtils.copyStream(response.stream, output);
            String htmlResponse = output.toString("UTF-8");
            if (!htmlResponse.contains("<blockquote")) {
                int start = htmlResponse.indexOf("<h1 style=\"text-align: center\">");
                if (start != -1) {
                    int end = htmlResponse.indexOf("<", start + 31);
                    if (end != -1) {
                        throw new Exception(htmlResponse.substring(start + 31, end).trim());
                    }
                }
            }
        }
    } finally {
        if (response != null) response.release();
    }
    return null;
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:34,代码来源:WakachanModule.java


示例20: getEntity

import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity; //导入依赖的package包/类
@Override
public HttpEntity getEntity(ResponseHandlerInterface progressHandler) throws IOException {
    return new UrlEncodedFormEntity(getParamsList(), contentEncoding);
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:5,代码来源:StringParams.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RegisterNodeManagerRequest类代码示例发布时间:2022-05-22
下一篇:
Java CompletionProposalInvocationContext类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap