写了一个android登陆论坛的程序 但是怎么都登陆不上去 到底问题是什么呢 郁闷呐 List <NameValuePair> params = new ArrayList <NameValuePair>();
params.add(new BasicNameValuePair("username",UserName));
params.add(new BasicNameValuePair("password", Password));
String sourceString = Net.getInstance().post("http://zhixing.bjtu.edu.cn/member.php?mod=logging&action=login", params); Net.getInstance().post函数是这样的 public String post(String URL,List <NameValuePair> params) throws Exception
{
String resultString;
try {
HttpPost httpRequest = new HttpPost(URL);
// httpRequest.setEntity(new UrlEncodedFormEntity(params, "GB2312"));
httpRequest.setEntity(new UrlEncodedFormEntity(params,HTTP.UTF_8));
HttpResponse httpResponse = client.execute(httpRequest);
if(httpResponse.getStatusLine().getStatusCode() == 200)
{
resultString= readstream(httpResponse.getEntity().getContent());
Log.v(URL, resultString);
}else {
throw new Exception("can't connect the network");
}
return resultString;
}catch (Exception e) {
throw e;
}
}每次都是登陆失败 帮忙看看有什么问题
params.add(new BasicNameValuePair("username",UserName));
params.add(new BasicNameValuePair("password", Password));
String sourceString = Net.getInstance().post("http://zhixing.bjtu.edu.cn/member.php?mod=logging&action=login", params); Net.getInstance().post函数是这样的 public String post(String URL,List <NameValuePair> params) throws Exception
{
String resultString;
try {
HttpPost httpRequest = new HttpPost(URL);
// httpRequest.setEntity(new UrlEncodedFormEntity(params, "GB2312"));
httpRequest.setEntity(new UrlEncodedFormEntity(params,HTTP.UTF_8));
HttpResponse httpResponse = client.execute(httpRequest);
if(httpResponse.getStatusLine().getStatusCode() == 200)
{
resultString= readstream(httpResponse.getEntity().getContent());
Log.v(URL, resultString);
}else {
throw new Exception("can't connect the network");
}
return resultString;
}catch (Exception e) {
throw e;
}
}每次都是登陆失败 帮忙看看有什么问题
android 登录Javaeye(使用HttpURLConnection和HttpClient)
http://blog.csdn.net/dellheng/article/details/7063373