80,351
社区成员
发帖
与我相关
我的任务
分享
public void doPost(View view) throws IOException {
new Thread(new Runnable() {
@Override
public void run() {
try {
final String lt= Jsoup.connect(html1).get().select("input[name='lt']").val();
final String execution= Jsoup.connect(html1).get().select("input[name='execution']").val();
RequestBody body=new FormBody.Builder()
.add("lt",lt)
.add("execution",execution)
.add("_ecentId","submit")
.add("rmShown","1")
.add("username",username)
.add("password",password)
.build();
Request.Builder builder=new Request.Builder();
Request request=builder.url(html1).post(body).build();
executeRequest(request);
} catch (IOException e) {
}
}
}).start();
}
private void executeRequest(Request request) {
Call call = okHttpClient.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
tv1.setText("登陆失败");
}
@Override
public void onResponse(Call call, Response response) throws IOException {
L.e("onResponse:");
final String res=response.body().string();
L.e(res);
runOnUiThread(new Runnable() {
@Override
public void run() {
tv1.setText(res);
}
});
}
});
}
public String html1="http://ids.wbu.edu.cn/authserver/login?service=http://my.wbu.edu.cn/index.portal";