作者:叶葳蕤1095190287 | 来源:互联网 | 2023-09-09 11:55
登录结果{"body":"","message":"Bad Request","status":400}
感觉是请求缺少了校验,但是不知道怎么完整的请求过程
之前http请求的时候,还可以用wireshark看请求过程,对比一下还可以看自己哪里错了
1 个解决方案
String loginurl="https://v4.passport.sohu.com/i/login/101305"
String userid=url;
String password=md5Util.Pd(passwords);
System.out.println(password);
String appid="101305";
String callback="";
//登录所需参数
List list=new ArrayList();
list.add(new BasicNameValuePair("userid", userid));
list.add(new BasicNameValuePair("password", password));
list.add(new BasicNameValuePair("appid", appid));
//list.add(new BasicNameValuePair("callback", callback));
//发送请求
HttpPost httpPost=new HttpPost(loginurl);
UrlEncodedFormEntity uefEntity=new UrlEncodedFormEntity(list, "UTF-8");
httpPost.setEntity(uefEntity);
//设置头部参数
httpPost.setHeader("Content-Type","text/html;charset=UTF-8");
httpPost.setHeader("User-Agent", "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0");
//接收相应
CloseableHttpResponse respOnse=httpclient.execute(httpPost, context);
System.out.println("状态码"+response.getStatusLine().getStatusCode());
HttpEntity Entity=response.getEntity();
String result=EntityUtils.toString(Entity,"utf-8");
System.out.println("登录结果"+result);