【发布时间】:2013-03-12 07:14:08
【问题描述】:
首先,我尝试能够发送带有以下参数的 HttpResponse:
代码如下所示:
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://www.syslang.com/frengly/controller");
List<NameValuePair> pairs = new ArrayList<NameValuePair>();
pairs.add(new BasicNameValuePair("src", "en"));
pairs.add(new BasicNameValuePair("dest", "iw"));
pairs.add(new BasicNameValuePair("text", "good"));
pairs.add(new BasicNameValuePair("email", "YYY"));
pairs.add(new BasicNameValuePair("password", "XXX"));
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(pairs,HTTP.UTF_8);
httpPost.setEntity(entity);
HttpResponse response = httpClient.execute(httpPost);
HttpEntity httpEntity = response.getEntity();
API structure is available at http://www.frengly.com/ (under the API tab) 共有 5 个参数(src、dest、text、email、password)。
到目前为止,我每次尝试拨打电话
HttpResponse 响应 = httpClient.execute(httpPost); 我不断收到 IO 异常 :(
之后我应该得到类似这样的结构:
-<root>
<text>good</text>
<translation>טוב</translation>
<translationFramed>טוב|</translationFramed>
<missing/>
<existing>good,</existing>
<stat>1/1</stat>
</root>
我想我会处理这部分来构建 XML 并根据需要解析它
ps:我查过了 Android, send and receive XML via HTTP POST method 和许多其他链接,这对我没有多大帮助。
如果需要我的应用程序中的任何代码行,请告诉我...
提前致谢。
【问题讨论】:
标签: android xml api xmlhttprequest http-post