急!!关于模拟登陆的,post了数据却登陆不了

qq_33190755 2017-10-20 12:25:28
这个是代码:



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);
}
});

}
});
}



不知道为何登陆不了
...全文
306 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_33190755 2017-10-26
  • 打赏
  • 举报
回复
引用 1 楼 f839903061 的回复:
打断点调试,看看你的onResponse方法有没有被调用!你模拟的数据是从什么地方请求的?
被调用了,因为我在这个方法里打印了一个Log只要调用就打印onResponse我看了的,它里面有
qq_33190755 2017-10-26
  • 打赏
  • 举报
回复
引用 1 楼 f839903061 的回复:
打断点调试,看看你的onResponse方法有没有被调用!你模拟的数据是从什么地方请求的?
从我们学校登陆的网页
qq_33190755 2017-10-26
  • 打赏
  • 举报
回复
引用 2 楼 u013894546 的回复:
不发个地址出来谁知道
啊这个是地址
    public String  html1="http://ids.wbu.edu.cn/authserver/login?service=http://my.wbu.edu.cn/index.portal";
Yunc2 2017-10-26
  • 打赏
  • 举报
回复
不发个地址出来谁知道
雨焰 2017-10-23
  • 打赏
  • 举报
回复
打断点调试,看看你的onResponse方法有没有被调用!你模拟的数据是从什么地方请求的?

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧