httpwebrequest怎么处理自动跳转(登录QQ空间)

thestronger 2009-12-25 09:33:54
想做一个在手机上登录QQ空间的程序,用的是httpwebrequest类。
用Fiddler抓了用OPERA登录QQ空间时的HTTP包,发现首先是打开"http://ptlogin2.qq.com/login",输入帐号密码验证码之后,如果输入正确自动跳转到"http://imgcache.qq.com/qzone/v5/loginsucc.html?para=izone",然后再打开 "http://user.qzone.qq.com/XXXXXXXXX"。
我用Httpwebrequest登录"http://ptlogin2.qq.com/login"后,发现它不能自动跳转,就算设置AllowAutoRedirect = True也是不行。Httpwebrequest中显示“Expect: 100-continue”。请问各位怎么处理?

我又重新用Httpwebrequest的GET方法自行连接"http://imgcache.qq.com/qzone/v5/loginsucc.html?para=izone"。结果这里在OPERA中返回的BODY长度为0。Httpwebrequest返回的长度却为6723。内容是以下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>登录成功 - V5</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="../qzfl/appclientlib.js" charset="utf-8"></script>
<script type="text/javascript">
//<![CDATA[
//document.domain="qq.com";

//关闭弹出窗口
function closePopup(){
var _self = parent.QZONE.FrontPage.showLoginBox;
if(_self==undefined){
parent.closePopup();
}else{
if (_self._ppml) {
parent.QZONE.maskLayout.remove(_self._ppml);
_self._ppml = null;
}
if (_self._dialog) {
_self._dialog.unload();
_self._dialog = null;
}
}
}
function getCookie(name){var r=new RegExp("(\\b)"+name+"=([^;]*)(;|$)");var m=document.cookie.match(r);return(!m?"":m[2]);}

function setLoginStatus() {
if(typeof(top.g_OFPLite)!="undefined"){
return;//独立版不需要这个逻辑
}
try {
// if (parent.g_version == 5) {
if(parent.g_iUin == parent.g_iLoginUin) {
parent.ownermode = true;
parent.QZONE.space.updateCSS(".ownerMode","display","inline");
parent.QZONE.space.updateCSS(".clientMode","display","none");
}else{
parent.ownermode = false;
parent.QZONE.space.updateCSS(".ownerMode","display","none");
parent.QZONE.space.updateCSS(".clientMode","display","inline");
}
/* }else{
parent.toolbarRefresh();

if(parent.g_iUin == parent.g_iLoginUin) {
parent.ownermode = true;
parent.insertCSS(0, ".ownerMode", "display:'inline'");
parent.insertCSS(0, ".clientMode", "display:none");
}
else {
parent.ownermode = false;
parent.insertCSS(0, ".clientMode", "display:'inline'");
parent.insertCSS(0, ".ownerMode", "display:none");
}

parent.updateAllModuleTitle(parent.ownermode);
}*/
}catch(err) {}
}

function spaceURL2uid(s){
if(!s) {
s=parent.location.href;
}

var re1=/http:\/\/user\.qzone\.qq\.com\/(\d{5,10})/i;
var re2=/http:\/\/(\d{5,10})\.qzone\.qq\.com/i;
var re3=/http:\/\/([\w\-\d]+)\.qzone\.qq\.com/i;
var re4=/http:\/\/imgcache\.qq\.com\/[^\d]+(\d{5,10})/i;
var re5=/http:\/\/qzone\.qq\.com\/blog\/(\d{5,10})-(\d+)/i;
if(re1.test(s))
return (re1.exec(s))[1];
else if(re2.test(s))
return (re2.exec(s))[1];
else if(re3.test(s)){
var tmp=(re3.exec(s))[1];
if(tmp=="new"){
return parent.g_iUin;
}else return tmp;
}
else if(re4.test(s))
return (re4.exec(s))[1];
else if(re5.exec(s))
return (re5.exec(s))[1];
else
return parent.g_iUin;
}

function getParameter(name,cancelBubble){
var r = new RegExp("(\\?|#|&)"+name+"=([^&#]*)(&|#|$)");
var m = location.href.match(r);
if ((!m || m=="") && !cancelBubble) m = parent.location.href.match(r);
return (!m?"":m[2]);
}

function showMsg(html){
parent.QZFL.widget.msgbox.show(html,0,3000);
}

function loginInit(){
var s=getParameter("para",true),
r = getParameter("refresh",true),
h = getParameter("home",true),
appid = getParameter("appid",true);
var t=parseInt(getCookie("uin").replace(/^o0*(\d{5,10})$/,"$1"),10);
parent.g_iLoginUin=isNaN(t)?0:t;
//p=(!!parent.closePopup)?parent.closePopup:function(){alert(parent.closePopup)};
if (s) {
setLoginStatus();
}

if(h == "1" && !isNaN(appid)){
QZONE.FP.getCurrentAppWindow().src =QZONE.FP.toApp(s);
closePopup();
return;
}else if(r == "1"){
QZONE.FP.getCurrentAppWindow().location.reload();
closePopup();
return;
}

if(s=="interact"){
parent.location = "http://rc.qzone.qq.com/interact";
return;
}else if(s=='izone'){
parent.location = "http://user.qzone.qq.com/"+t;
}else if(s == 'reload'){
parent.location.reload(true);
return;
}
else if(s=="mall"){
closePopup();
}
else if(s=="BBS"){
var f=parent.document.getElementById("tbbs");
if(!!f && f.contentWindow)
f.contentWindow.verify();
closePopup();
}
else if(s=="club"){
var f=parent.document.getElementById("ic");
if(!!f && f.contentWindow)
f.contentWindow.loginCallback();
closePopup();
}
else if(s=="blogComment" || s=="moodComment"){
var f=!!parent.isStatic?top:parent.document.getElementById("tblog");
if(!parent.isStatic && !!f && f.contentWindow)
f.contentWindow.loginCallback();
else if(!!parent.isStatic){
f.loginCallback();
}
showMsg("登录成功");
closePopup();
}
else if(s=="mgbComment"){
var f=parent.document.getElementById("tgb");
try {
if(!!f && f.contentWindow) {
f.contentWindow.loginCallback();
}
}
catch (err) {
}

showMsg("登录成功");
closePopup();
}
else if(s=="photo"){
var f=parent.document.getElementById("tphoto");
if(!!f && f.contentWindow)
f.contentWindow.LoginBack();
showMsg("登录成功");
closePopup();
}
else if(s=="act"){
var f=parent.document.getElementById("act");
if(!!f && f.contentWindow)
f.contentWindow.loginCallback();
showMsg("登录成功");
closePopup();
}
else if(s=="ownerOperation"){ //在进行主人态操作时候,如果用户登录超时,弹出登陆框的时候使用
showMsg("登录成功");
closePopup();
if(parent.g_iUin != parent.g_iLoginUin) {
parent.location.href="http://user.qzone.qq.com/"+spaceURL2uid();
return;
}
}
else if(s=="driftbottle") {
showMsg("登录成功");
closePopup();
//if(parent.g_iUin != parent.g_iLoginUin) {
if(!!parent.dbLoginCallback) parent.dbLoginCallback();
parent.dbLoginCallback = null;
// return;
//}
}
else if(s=="soren") {
showMsg("登录成功");
closePopup();
if(!!parent.sorenLoginback) parent.sorenLoginback();
return;

}
else if(s=="music"){
showMsg("登录成功");
closePopup();
var f=parent.document.getElementById("tmusic");
if(!!f && f.contentWindow)
f.contentWindow.loginCallback();
return;
}
else if(s=="zhen"){
closePopup();
if(parent.loginCallback)parent.loginCallback();
return;
}
else if(s=="app"){
var l2Win = parent.QZONE.space.getL2Window();
if(l2Win.loginCallback) l2Win.loginCallback();
try{
parent.toolbarRefresh();
}catch(err){}
closePopup();
return;
}
else{
parent.location.href="http://user.qzone.qq.com/"+spaceURL2uid();
return;
}
}

loginInit();
//]]>
</script>
</head>
<body></body>
</html>
<!--[if !IE]>|xGv00|82c49dfb0ca54a144f791646867a658a<![endif]-->


结果就是登录不成功,请问大家这又怎么处理。
...全文
1901 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
thestronger 2009-12-28
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 clonecenter 的回复:]
是不是 cookie 的问题?
[/Quote]
我抓了IE的数据包,把所有的出现的COOKIE都给加上去了,还是不行
CloneCenter 2009-12-26
  • 打赏
  • 举报
回复
是不是 cookie 的问题?

16,555

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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