0
我有一个计划,使安卓网络解析后,使自动登录服务... 但我有一个问题... 我尝试解析到http://communion.gntc.net/我看到www.w3.org/xhtml。 .. XHTML ...如何让自动登录服务......只是我知道使用登录“后法”如何Android的XHTML解析
来源尝试URL连接,并尝试登录,但我不能登录。只是......登录再读流信号源画面...... main.java(某些部分)
public class Main extends SherlockActivity {
........
public class async_Login extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... params) {
try {
// URL setting
communion_Url = new URL("http://communion.gntc.net/Default.aspx");
connection = (HttpURLConnection) communion_Url .openConnection();
// <Form> setting
connection.setRequestProperty("content-type", "application/x-www-form-urlencoded");
// method choose
connection.setRequestMethod("POST");
// transfer mode
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches(false);
connection.setDefaultUseCaches(false);
// server input info
StringBuffer buffer = new StringBuffer();
buffer.append("__VIEWSTATE").append("=").append("%2FwEPDwUKLTIyMDExNjMxNA9kFgICAw9kFgICAw9kFgICBw9kFgICAQ9kFgICCQ8QZGQWAGQYAgUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgEFFExvZ2luVmlldzEkaWJ0bkxvZ2luBRZMb2dpblZpZXcxJG12TG9naW5WaWV3Dw9kZmQyduUiycnsslmd80DsHFWnE%2F5ewQ%3D%3D").append("&");
buffer.append("__EVENTVALIDATION").append("=").append("%2FwEWBAK%2F9LzRAwK73JjWBAKVqtrbDwLeooalDbXptfMUzAby%2FyAzoqPXkmhJ%2Bq6x").append("&");
buffer.append("LoginView1%24txtID").append("=").append(params[0]).append("&"); //ID values
buffer.append("LoginView1%24ibtnLogin.x").append("=").append("1").append("&");
buffer.append("LoginView1%24ibtnLogin.y").append("=").append("1").append("&");
buffer.append("LoginView1%24txtPW").append("=").append(params[1]); // PS values
fileSave(buffer.toString());
OutputStream opstrm = new BufferedOutputStream(connection.getOutputStream());
opstrm.write(buffer.toString().getBytes());
opstrm.flush();
opstrm.close();
connection.setRequestMethod("GET");
InputStream is = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
StringBuffer response = new StringBuffer();
while((line = rd.readLine()) != null) {
response.append(line);
response.append('\r');
}
rd.close();
//fileSave(response.toString());
Log.i("#async_Login#", response.toString());
} catch (IOException e) {
Log.i("##async_Login##", "Communion Connect Failure");
//e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String result) {
}
}
.........
}
为什么尝试使用GET方法?我上传图片你看到 - > [图片](http://cfile6.uf.tistory.com/original/26110B39518A35E413B459) – 2013-05-08 11:25:40
不要尝试GET,但删除它。你正在调用'setRequestMethod'两次。 – koral 2013-05-08 20:24:34
啊!!!我很抱歉,我明白了!这是我的错误 但是...删除GET方法,我有同样的问题... 无法登录 – 2013-05-16 04:44:29