无法接收 Atom feed
我使用常用代码接收 XML 格式的提要并将其存储为字符串,但收到“unknownhostexception”。
链接: http://android-tv-app.com/Hls8zUWPqa9C2U/feed/atom< /a>
代码:
String answer = null;
HttpUriRequest request = null;
HttpResponse resp = null;
InputStream is = null;
DefaultHttpClient client = new DefaultHttpClient();
client.getParams().setParameter("http.socket.timeout", new Integer(10000));
try {
request = new HttpGet(url);
request.setHeader("Accept-Encoding","gzip,deflate");
resp = client.execute(request);
if (resp.getStatusLine().getStatusCode() != 200)
{
error = 3;
return null;
}
HttpEntity entity = resp.getEntity();
is = entity.getContent();
return convertStreamToString(is);
} catch (Exception e)
{
error = 3;
return null;
}
更新 1:
这可能是我的问题,有人可以解释一下吗:
包括在 XHTML 中 应将以下标记放置在 XHTML 文档的头部,以提供指向 ATOM Feed 的链接。
来自
http://en.wikipedia.org/wiki/Atom_%28standard %29#Atom_compared_to_RSS_2.0
I am using my usual code to receive a feed in XML and store it as a String, but getting an "unknownhostexception".
link: http://android-tv-app.com/Hls8zUWPqa9C2U/feed/atom
code:
String answer = null;
HttpUriRequest request = null;
HttpResponse resp = null;
InputStream is = null;
DefaultHttpClient client = new DefaultHttpClient();
client.getParams().setParameter("http.socket.timeout", new Integer(10000));
try {
request = new HttpGet(url);
request.setHeader("Accept-Encoding","gzip,deflate");
resp = client.execute(request);
if (resp.getStatusLine().getStatusCode() != 200)
{
error = 3;
return null;
}
HttpEntity entity = resp.getEntity();
is = entity.getContent();
return convertStreamToString(is);
} catch (Exception e)
{
error = 3;
return null;
}
Update 1:
This could be my problem, Can someone explain this:
Including in XHTML
The following tag should be placed into the head of an XHTML document to provide a link to an ATOM Feed.
from
http://en.wikipedia.org/wiki/Atom_%28standard%29#Atom_compared_to_RSS_2.0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这通常意味着您没有连接到互联网。
在手机/模拟器的浏览器中检查您的互联网连接。
简单地说,在这种情况下最好的办法是优雅地处理异常并通知用户他/她没有连接到互联网。
It usually means you are not connected to the internet.
Check your internet connection in the phone's/emulator's browser.
Plainly said, the best thing to do in such cases is to handle the exception gracefully and inform the user he/she is not connected to the internet.