iTunes 12.0 x64版本。QQ 9292 0 4200
private iTunesDownloadErrorState LoginApp(iTunesUserInfo appleAccountInfo_0)
{
iTunesDownloadErrorState succeed = iTunesDownloadErrorState.Succeed;
Dictionary<object, object> objPlist = new Dictionary<object, object>();
objPlist.Add("appleId", appleAccountInfo_0.UserName);
objPlist.Add("attempt", "1");
objPlist.Add("createSession", true);
objPlist.Add("guid", appleAccountInfo_0.Guid);
objPlist.Add("machineName", appleAccountInfo_0.MachineName);
objPlist.Add("password", appleAccountInfo_0.Password);
objPlist.Add("why", "signIn");
string s = tool.CreatePlistString(objPlist);
Label_0084:
appleAccountInfo_0.IsAreaChanged = false;
DateTime now = DateTime.Now;
while (DateTime.Now.Subtract(now).TotalSeconds < 120.0)
{
try
{
string str5 = string.Format("https://p{0}-buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/authenticate", appleAccountInfo_0.ServerId);
string str6 = string.Format("https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewGrouping?cc={0}&mt=8", GetAreaByDescription(appleAccountInfo_0.StoredDescrption));
byte[] bytes = Encoding.UTF8.GetBytes(s);
string str7 = string.Empty;
if (NewLogin)
{
str7 = Convert.ToBase64String(this.GetSignsapsetupcertbyte(appleAccountInfo_0.StoredDescrption, bytes));
}
HttpWebRequest request = this.SetiTunesHtppHeaders(str5, bytes, str6, appleAccountInfo_0.StoredDescrption, str7,appleAccountInfo_0);
request.ContentType = "application/x-apple-plist";
string str8 = "";
string str9 = this.GetiTunesHtpp(request, ref str8, appleAccountInfo_0);
if (!string.IsNullOrEmpty(str9) && (str8 == ""))
{
//if (!appleAccountInfo_0.IsAreaChanged)
{
appleAccountInfo_0.PlistContent = str9;
}
request = null;
break;
}
appleAccountInfo_0.ServerId = this.GetServerId(str8);
request = null;
}
catch (Exception exception)
{
}
continue;
}
//if (appleAccountInfo_0.IsAreaChanged)
{
// goto Label_0084;
}
if (appleAccountInfo_0.PlistContent.Length == 0)
{
succeed = iTunesDownloadErrorState.WebCannotAnalyse;
}
else
{
//MessageBox.Show(appleAccountInfo_0.PlistContent);
string str3 = this.GetKeyValue("<key>failureType</key>", "<string>", "</string>", appleAccountInfo_0.PlistContent);
string str2 = this.GetKeyValue("<key>customerMessage</key>", "<string>", "</string>", appleAccountInfo_0.PlistContent);
if ((str2.Length <= 0) && (str3.Length <= 0))
{
if (str2.Length > 0)
{
if (str2.Contains("https://iforgot.apple.com"))
{
succeed = iTunesDownloadErrorState.LoginiTunesDisable;
}
else
{
succeed = iTunesDownloadErrorState.UnKnow;
}
}
//您的 Apple ID 或密码输入有误
else if ((str3.Length == 0) && (str2.Length == 0))
{
string str4 = this.GetKeyValue("<key>message</key>", "<string>", "</string>", appleAccountInfo_0.PlistContent);
if ((str4.Length > 0) && str4.StartsWith("This Apple ID is only valid for purchases"))
{
succeed = iTunesDownloadErrorState.LoginInOtherStore;
Nt.LoggerService.ULogger.Debug(appleAccountInfo_0.PlistContent);
}
}
}
else if (appleAccountInfo_0.PlistContent.IndexOf("或密码输入有误") > 0 || appleAccountInfo_0.PlistContent.IndexOf("Your Apple ID or password was entered incorrectly") > 0)
{
succeed = iTunesDownloadErrorState.LoginException;
//写放数据
/*
if (_errorLogin.InsertDbLogin(new errorLoginUser { userName = appleAccountInfo_0.UserName, pwd = appleAccountInfo_0.Password }) > 0)
{
Nt.LoggerService.ULogger.Debug(string.Format("********用户:{0}, 登录或密码错误, 数据已经写入数据库********", appleAccountInfo_0.UserName));
}
else
{
Nt.LoggerService.ULogger.Debug(string.Format("********用户:{0}, 登录或密码错误, 数据未写入数据库!********", appleAccountInfo_0.UserName));
}
*/
}
else if (appleAccountInfo_0.PlistContent.IndexOf("您的帐户已被禁用") > 0 && appleAccountInfo_0.PlistContent.IndexOf("以重新设置您的帐户") > 0)
{
succeed = iTunesDownloadErrorState.NeedSecurityCode;
}
else if (appleAccountInfo_0.PlistContent.IndexOf("您的帐户已被禁用") > 0)
{
succeed = iTunesDownloadErrorState.LoginiTunesDisable;
}
else if (appleAccountInfo_0.PlistContent.IndexOf("<key>failureType</key>") > 0)
{
succeed = iTunesDownloadErrorState.LoginiTunesDisable;
Nt.LoggerService.ULogger.Debug(appleAccountInfo_0.PlistContent);
}
else
{
succeed = iTunesDownloadErrorState.UnKnow;
}
}
return succeed;
}