我正在寻求帮助!我有一些代码执行服务器身份验证并从服务器检索响应。当我在我的java项目中的eclipse中执行它时,我得到了reddirrect响应,例如:
<html><head><meta http-equiv="refresh" content="0;url=SiteIamLoggingPageURL/"/></head></html>
但是当我在我的 android 应用程序中执行相同的代码时,我得到的响应等于登录失败的场景。
HttpPost post = new HttpPost(loginPageAdress);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
//nameValuePairs.add(new BasicNameValuePair("remember", "1"));
nameValuePairs
.add(new BasicNameValuePair("email", "email"));
nameValuePairs.add(new BasicNameValuePair("password", "password"));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs, "utf-8"));
StringBuilder stringBuilder = new StringBuilder();
HttpResponse response = client.execute(post, httpContext);
BufferedReader rd = new BufferedReader(new InputStreamReader(response
.getEntity().getContent(), "UTF-8"));
String line = "";
while ((line = rd.readLine()) != null) {
stringBuilder.append(line).append("\n");
}
System.out.println(stringBuilder.toString());
问题是什么?o 感谢您的宝贵时间!