httpclient模拟登录web版新浪微博

httpclient模拟登录web版新浪微博

ID:34723305

大小:55.51 KB

页数:5页

时间:2019-03-10

httpclient模拟登录web版新浪微博_第1页
httpclient模拟登录web版新浪微博_第2页
httpclient模拟登录web版新浪微博_第3页
httpclient模拟登录web版新浪微博_第4页
httpclient模拟登录web版新浪微博_第5页
资源描述:

《httpclient模拟登录web版新浪微博》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、HttpClient模拟登录Web版新浪微博上篇介绍了如何模拟登录手机版微博,过程还是比较简单的,没有设计到复杂的加密部分。登录Web版微博的过程还是一样的,只不过这次需要提交的数据多一点。publicstaticCookie[]getWCookies(Stringusername,Stringpassword)throwsHttpException,IOException{HttpClientclient=null;PostMethodpost=null;GetMethodget=null;t

2、ry{client=newHttpClient();client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);post=newPostMethod("http://login.sina.com.cn/sso/login.php?client=ssologin.js(v1.3.16)");Stringdata=getServerTime();Stringnonce=makeNonce(6);NameValuePai

3、r[]nvps=newNameValuePair[]{newNameValuePair("entry","weibo"),newNameValuePair("gateway","1"),newNameValuePair("from",""),newNameValuePair("savestate","7"),newNameValuePair("useticket","1"),newNameValuePair("ssosimplelogin","1"),newNameValuePair("vsnf

4、","1"),newNameValuePair("vsnval",""),newNameValuePair("su",encodeAccount(username)),newNameValuePair("service","miniblog"),newNameValuePair("servertime",data),newNameValuePair("nonce",nonce),newNameValuePair("pwencode","wsse"),newNameValuePair("sp",n

5、ewSinaSSOEncoder().encode(password,data,nonce)),newNameValuePair("encoding","UTF-8"),newNameValuePair("returntype","META"),newNameValuePair("url","http://weibo.com/ajaxlogin.php?framelogin=1&callback=parent.sinaSSOController.feedBackUrlCallBack")};po

6、st.setRequestBody(nvps);client.executeMethod(post);Stringurl=post.getResponseBodyAsString().substring(post.getResponseBodyAsString().indexOf("http://weibo.com/ajaxlogin.php?"),post.getResponseBodyAsString().indexOf("code=0")+6);get=newGetMethod(url);

7、client.executeMethod(get);}catch(IOExceptione){e.printStackTrace();}finally{get.abort();post.abort();}returnclient.getState().getCookies();}其中密码部分进行了加密,加密的算法在网页的js文件里,网上有人把它改成了Java代码。下面是SinaSSoEncoder类:publicclassSinaSSOEncoder{privatebooleani=false;

8、privateintg=8;publicSinaSSOEncoder(){}publicStringencode(Stringpsw,Stringservertime,Stringnonce){Stringpassword;password=hex_sha1(""+hex_sha1(hex_sha1(psw))+servertime+nonce);returnpassword;}privateStringhex_sha1(Stringj){returnh(b(f(j,j.length()*g),

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。