总共三次请求:
第一次目的获取 nonce servertime pubkey rsakv pcid
第二次目的获取 ticket loginUrl
第三次目的获取 Cookie
1.将用户名先urlencode编码再Base64Encode编码
2.根据http://login.sina.com.cn/sso/prelogin.php?entry=weibo&callback=sinaSSOController.preloginCallBack&su=二次编码后的用户名&rsakt=mod&checkpin=1&client=ssologin.js(v1.4.5)&_=System.currentTimeMillis() url来构造HttpGet
3.添加请求头
headers.put("Accept", "*/*"); headers.put("Referer", "http://weibo.com/"); headers.put("Accept-Language", "zh-cn"); headers.put("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; QQDownload 691)"); headers.put("Host", "login.sina.com.cn"); headers.put("Connection", "Keep-Alive");</span>4.抛出Get请求后 能够从响应中获得nonce servertime pubkey rsakv pcid这几个值
headers.put("Accept", "text/html, application/xhtml+xml, */*");//Accept: */*\r\n headers.put("Referer", "http://login.sina.com.cn/member/my.php?entry=sso"); headers.put("Accept-Language", "zh-cn"); headers.put("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; BOIE9;ZHCN"); headers.put("Host", "login.sina.com.cn"); headers.put("Connection", "Keep-Alive"); headers.put("Content-Type", "application/x-www-form-urlencoded"); headers.put("Cache-Control", "no-cache");</span>8.向HttpPost中添加参数
params.put("encoding", "UTF-8"); params.put("entry", "weibo"); params.put("from", ""); params.put("prelt", "112"); params.put("gateway", "1"); params.put("nonce", nonce); params.put("pwencode", "rsa2");//wsse params.put("returntype", "META"); params.put("pagerefer", ""); params.put("savestate", "7"); params.put("servertime", servertime); params.put("rsakv", rsakv); params.put("service", "miniblog"); params.put("sp", 二次编码后的用户名); params.put("ssosimplelogin", "1"); params.put("su", 加密后的密码); params.put("url", "http://weibo.com/ajaxlogin.php?framelogin=1&callback=parent.sinaSSOController.feedBackUrlCallBack"); params.put("useticket", "1"); params.put("vsnf", "1");</span>9.Post请求后从响应中获取ticket loginUrl
http://download.csdn.net/detail/onepiecehuiyu/8931417