I would like to fetch data from a phpMyAdmin server. The only function I know, is this :
private String getPage() {
String str = "***";
try
{
HttpClient hc = new DefaultHttpClient();
HttpPost post = new HttpPost("http://mywebsite.me");
HttpResponse rp = hc.execute(post);
if(rp.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
{
str = EntityUtils.toString(rp.getEntity());
}
}catch(IOException e){
e.printStackTrace();
}
return str;
}
由于我需要用用户名和密码来认证自己,这并不成功。 我认为,这一职能不会奏效的另一个原因是,它占用了该网页的源头(ctrl+u,在“ Chrome”中,以及我所需要的数值,这些数值列在服务器上。 我如何能够这样做?