评论张贴在Android的一个词preSS-博客 [英] Posting comments to a wordpress-blog in Android

查看:76
本文介绍了评论张贴在Android的一个词preSS-博客的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的模块,允许用户对字preSS发表了一篇博客发表评论上。我看了看HTML源后评论表格在博客条目的底部(发表评论部分)显示。使用作为参考,我用它翻译成Java DefaultHTTPClient BasicNameValuePairs 和我的code样子:

I am working on a module that allows users to post comments on a blog published on Wordpress. I looked at the HTML source for Post-Comment-Form displayed at the bottom of a blog entry (Leave a Reply section). Using that as a reference, I translated it to Java using DefaultHTTPClient and BasicNameValuePairs and my code looks like:

DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://xycabz.wordpress.com/wp-comments-post.php");
httppost.setHeader("Content-type","application/x-www-form-urlencoded;charset=UTF-8");

List<NameValuePair> nvps = new ArrayList<NameValuePair>();

nvps.add(new BasicNameValuePair("author","abc"));
nvps.add(new BasicNameValuePair("email","abz@xyc.com"));
nvps.add(new BasicNameValuePair("url",""));         
nvps.add(new BasicNameValuePair("comment","entiendamonos?"));
nvps.add(new BasicNameValuePair("comment_post_ID","123"));
//this was a hidden field and always set to 0
nvps.add(new BasicNameValuePair("comment_parent","0"));

try {
    httppost.setEntity(new UrlEncodedFormEntity(nvps));
} catch (UnsupportedEncodingException e1) {
    e1.printStackTrace();
}

BasicResponseHandler handler = new BasicResponseHandler();


try {

    Log.e("OUTPUT",httpclient.execute(httppost,handler));
} catch (ClientProtocolException e) {               
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}

我得到 HTTP 302找到(重定向到临时位置)在日志中的异常与此code,这是我忽视。 (注:通常,当您发表评论(网页),你会回到那个报名所有评论博客页面,我的重定向获得的URL是一样的。)即使忽略此重定向后,我可以发布使用此code。关于我的个人博客评论,但不实际(生产)博客。

I get HTTP 302 Found (Redirect to temporary location) exceptions in the logs with this code, which I ignore. (Note: Usually, when you post a comment(on the web page) you are taken back to the blog page that enlists all the comments. The URL I am getting in the redirects is the same) Even after ignoring this redirect, I can post comments on my personal blog using this code but not on the actual (production) blog.

问题:结果
1.难道这是一个后一个注释设置问题(或许是原来的博客的主人可能已设置)?结果
2.如何处理的HTTPClient 302状态code?最后,我只需要通知的成功和失败的用户,并没有真正带他去评论页面。

Questions:
1. Could this be a post-a-comment settings problem(perhaps something the original blog owner might have set)?
2. How should HTTPClient handle 302 status code? Eventually, I just have to notify the user of success and failure and not actually take him to the comments page.

推荐答案

您可以检查的gravatar,Akismet在或其他一些评论相关插件ü创造的问题。
尝试使用海报检查输出和LiveHTTP头在Firefox扩展用于调试生产网站

You can check for gravatar, akismet or some other comment related plugins creating issues for u. Try checking the output using Poster and LiveHTTP headers extensions in Firefox for debugging the production website

这篇关于评论张贴在Android的一个词preSS-博客的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆