我正在制作一个android应用程序,它使用编码的JSON从网页中检索数据。在我进入网页浏览器的页面时,它要求我输入我的用户名和密码进行服务器身份验证。我如何做到这一点,当我做一个httpPost;它会发送一个用户名和密码,所以我可以访问该页面。Android httpClient服务器身份验证
它的这种身份认证http://www.wpwhitesecurity.com/wp-content/uploads/2012/08/web-server-authentication-dialogue-box.png
的我该怎么办呢?这里是我的代码:
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
HttpResponse httpResponse = null;
try {
httpResponse = httpClient.execute(httpPost);
} catch (ClientProtocolException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
} catch (IOException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
HttpEntity httpEntity = httpResponse.getEntity();
try {
is = httpEntity.getContent();
} catch (IllegalStateException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
你想用户名和密码到服务器与url..isn't它? –
它的这种服务器用户名和通过http://www.wpwhitesecurity.com/wp-content/uploads/2012/08/web-server-authentication-dialogue-box.png –