请教(新浪模拟登录)

haojuntu 2011-08-29 12:10:20

http://topic.csdn.net/u/20110827/22/d0c63b1f-4c28-48df-98b3-1fc5187d9f5d.html
大家帮忙看一下吧,代码如下,可是不能登录成功啊,先谢谢了。。

 private void SinaLogin_Load(object sender, EventArgs e)
{
string username = "";
string password = "";
string url = "http://login.sina.com.cn/sso/prelogin.php?entry=miniblog&callback=sinaSSOController.preloginCallBack&user=" + username + "&client=ssologin.js(v1.3.12)";
url = GetUrl(url);
try
{
if (!string.IsNullOrEmpty(url))
{
int a = url.LastIndexOf(',') - 10;
int b = url.LastIndexOf(':') + 2;
string servertime = url.Substring(a, 10);
string nonce = url.Substring(b, 6);
string Pwd1 = GetPwd(password);
string Pwd2 = GetPwd(Pwd1);
string Pwd3 = GetPwd(Pwd2 + servertime + nonce);
string login = @"http://login.sina.com.cn/sso/login.php?client=ssologin.js(v1.3.12)&service:miniblog&client:ssologin.js%28v1.3.12%29&entry:miniblog&encoding:utf-8&gateway:1&savestate:0&useticket:1&username:" + username + "&servertime:" + servertime + "&nonce:" + nonce + "&pwencode:wsse&password:"+Pwd3+"&url:http://www.baidu.com&returntype:META&ssosimplelogin:1";
string result = GetUrl(login);
}
else
{
Console.WriteLine("出错了!");
}
}
catch (Exception)
{

throw;
}


}
static string GetPwd(string Pwd)
{
byte[] data = System.Text.Encoding.Default.GetBytes(Pwd);//以字节方式存储
System.Security.Cryptography.SHA1 sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider();
byte[] result = sha1.ComputeHash(data);//得到哈希值
return System.BitConverter.ToString(result).Replace("-", ""); //转换成为字符串的显示
}

private string GetUrl(string url)
{
string _str = string.Empty;
WebRequest request = WebRequest.Create(url);

request.Timeout = 5000;
//request.Method = "POST";
try
{
WebResponse response = request.GetResponse();

StreamReader reader = new StreamReader(response.GetResponseStream(),System.Text.Encoding.GetEncoding("gb2312"));
_str = reader.ReadToEnd();
reader.Close();
reader.Dispose();
response.Close();

}
catch (System.Net.WebException ex)
{
//tb.Text = ex.Message;
}
return _str;
}
...全文
294 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
haojuntu 2011-10-29
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 netxuning 的回复:]

楼主你好,我最后得到如下结果:
sinaSSOController.loginCallBack({"retcode":"0","uid":"2420043227","crossDomainUrlList":["http:\/\/weibo.com\/sso\/crosdom?action=login","http:\/\/kandian.com\/logon\/do_crossdomain.p……
[/Quote]

你那只是第一部,获取两个参数吧。参考一下这个
http://blog.csdn.net/jk_yu520/article/details/6622661
netxuning 2011-10-25
  • 打赏
  • 举报
回复
楼主你好,我最后得到如下结果:
sinaSSOController.loginCallBack({"retcode":"0","uid":"2420043227","crossDomainUrlList":["http:\/\/weibo.com\/sso\/crosdom?action=login","http:\/\/kandian.com\/logon\/do_crossdomain.php?action=login","http:\/\/login.t.cn\/sinaurl\/sso.json?action=login&uid=2420043227"]});

retcode为0应该是代表登陆成功了吧?而且uid的值确实也是我新浪的ID,但,得到这个结果然后该怎么做呢?
haojuntu 2011-09-26
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 dandeyu 的回复:]
http://login.sina.com.cn/sso/login.php?client=ssologin.js(v1.3.14)

还有地址。。。
我是成功了。
[/Quote]

,谢谢,我的能登录了,最主要的是加密的密码要转为”小写“
dandeyu 2011-09-26
  • 打赏
  • 举报
回复
http://login.sina.com.cn/sso/login.php?client=ssologin.js(v1.3.14)

还有地址。。。
我是成功了。
dandeyu 2011-09-26
  • 打赏
  • 举报
回复
entry=weibo&gateway=1&from=&savestate=7&useticket=1&ssosimplelogin=1&username=yudedan%40sina.com&service=miniblog&servertime=1317022496&nonce=RP018S&pwencode=wsse&password=0aec2d93a23c6d2aaef04002f52e40c85d3244a6&encoding=utf-8&url=http%3A%2F%2Fweibo.com%2Fajaxlogin.php%3Fframelogin%3D1%26callback%3Dparent.sinaSSOController.feedBackUrlCallBack&returntype=META

这是最新的post数据,你分析一下吧,其实用火狐可以截取的。
子夜__ 2011-08-29
  • 打赏
  • 举报
回复
返回的是什么错误。
Ny-6000 2011-08-29
  • 打赏
  • 举报
回复
把错误提示贴出来,大家更好看了.
Ny-6000 2011-08-29
  • 打赏
  • 举报
回复
有何错误呢?
跟踪看看再说.
haojuntu 2011-08-29
  • 打赏
  • 举报
回复
自己顶一下。。
haojuntu 2011-08-29
  • 打赏
  • 举报
回复
大家帮我看一下啊,不知道我返回的为什么是那个结果?应该是那两种的一种才对的
haojuntu 2011-08-29
  • 打赏
  • 举报
回复
谢谢大家!
哦,我是参考这个做的
我返回的是这个结果

<html>
<head>
<title>新浪会员</title>
<meta http-equiv="refresh" content="0; url='http://login.sina.com.cn/signup/signin.php?'">
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000cc" vlink="#551a8b" alink="#ff0000">
<script type="text/javascript" language="javascript">
location.replace("http://login.sina.com.cn/signup/signin.php?");
</script>
</body>
</html>


62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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