我正在android平台上做一些关于谷歌阅读器的开发。
使用google reader api,我可以成功获取 RSS 列表。但是当我想将 RSS 项目标记为已读时,出现“需要 411 长度”错误。这是我的代码:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(
"http://www.google.com/reader/api/0/edit-tag");
httppost.addHeader("Authorization", auth);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("i", itemId));
nameValuePairs.add(new BasicNameValuePair("a",
"user/-/state/com.google/read"));
nameValuePairs.add(new BasicNameValuePair("async", "true"));
nameValuePairs.add(new BasicNameValuePair("T", token));
nameValuePairs.add(new BasicNameValuePair("s", feedUrl));
try {
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
Toast.makeText(getApplicationContext(),
EntityUtils.toString(response.getEntity()),
Toast.LENGTH_LONG).show();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
有什么不对的吗?