private String waitForLogin()
{
var url = String.Format("https://login.weixin.qq.com/cgi-bin/mmwebwx-bin/login?tip={0}&uuid={1}&_={2}", tip, uuid, get_timestamp());
Console.WriteLine(url);
var http = WebRequest.Create(url) as HttpWebRequest;
http.CookieContainer = cookieContainer;
var tuple = getResponseText(http, new UTF8Encoding(true, true));
var text = tuple.Item1;
Console.WriteLine(text);
var regex = @"window.code=(\d+);";
var r = new Regex(regex, RegexOptions.None);
Match m = r.Match(text);
var code = m.Groups[1].Value;
var response = (HttpWebResponse)tuple.Item2;
foreach (Cookie cookie in response.Cookies)
{
Console.WriteLine(String.Format("Cookie_in_wait_login: {0}, {1}", cookie.Name,cookie.Value));
}
if(code == "201")
{
updateUITextLine(info_display, "扫描成功,请在手机上点击确认以登录", Environment.NewLine, Color.Black);
tip = 0;
} else if(code == "200")
{
updateUITextLine(info_display, "正在登录", Environment.NewLine, Color.Black);
regex = @"window.redirect_uri=""(\S+?)"";";
r = new Regex(regex, RegexOptions.None);
m = r.Match(text);
redirect_url = m.Groups[1] + "&fun=new";
for (int i = redirect_url.Length - 1; i >= 0; i--)
{
if(redirect_url[i] == '/')
{
base_url = redirect_url.Substring(0, i + 1);
break;
}
}
} else if(code == "408")
{
// do nothing
}
return code;
}