mirror of
https://git.oceanpay.cc/danial/kami_itunes_june.git
synced 2025-12-18 22:31:24 +00:00
2977 lines
115 KiB
C#
2977 lines
115 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.IO;
|
||
using System.IO.Compression;
|
||
using System.Linq;
|
||
using System.Net;
|
||
using System.Security.Cryptography;
|
||
using System.Text;
|
||
using System.Text.RegularExpressions;
|
||
using System.Threading;
|
||
using System.Web;
|
||
using AppleBatch_June.Domain;
|
||
using AppleBatch_June.ExecuteTasks;
|
||
using AppleBatch_June.Model;
|
||
using AppleBatch_June.Utils;
|
||
using DotNet.Utilities;
|
||
|
||
namespace AppleBatch_June
|
||
{
|
||
public class ItunesUtlis : AppleNetworkBase
|
||
{
|
||
public class GameDataInfo
|
||
{
|
||
public string buyParams2 { get; set; }
|
||
|
||
public string pageId { get; set; }
|
||
|
||
public string page { get; set; }
|
||
|
||
public string pageType { get; set; }
|
||
|
||
public string metricsBase { get; set; }
|
||
}
|
||
|
||
private static readonly object objReddemLock = new object();
|
||
|
||
public string dirName = ConfigUtlis.path + "游戏获取失败记录\\" + DateTime.Now.ToString("yyyy-MM-dd-HH点mm分");
|
||
|
||
public PaymentInfo overcheckPayment { get; set; }
|
||
|
||
private string oldUserAgent { get; set; }
|
||
|
||
public ItunesUtlis(ITaskRunState _taskState, string _notyKey, Action<string, DisplyType, string> _action = null, bool _OpenVpn = false)
|
||
: base(_taskState, _notyKey, _action, _OpenVpn)
|
||
{
|
||
}
|
||
|
||
public void getGameList(AppleItunesLogin itunesLogin, string gameUrl)
|
||
{
|
||
}
|
||
|
||
public bool checkAccountRealNameState(string appleId)
|
||
{
|
||
if (SqliteHelper.ExecuteScalar("select * from itunes_db where value1='" + Tools.GetMD5_32(appleId + "123teluns") + "' and type='RealNameId'") == null)
|
||
{
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public CheckRealNameType CheckNeedRealName(AppleItunesLogin itunesLogin)
|
||
{
|
||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||
dictionary.Add("X-Apple-Store-Front", "143465-19,12");
|
||
HttpResult itunesWebContext = getItunesWebContext("https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/redeemLandingPage?cc=cn", "", itunesLogin, dictionary, addToken: true);
|
||
if (itunesWebContext.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
if (new Regex("MZFinance.woa/wa/redeemValidateId([\\s\\S]*?)nationalIdForm").Match(itunesWebContext.Html).Groups[1].Value.Contains("class=\"hide\""))
|
||
{
|
||
if (!checkAccountRealNameState(itunesLogin.account.Trim()))
|
||
{
|
||
Dictionary<string, string> dictionary2 = new Dictionary<string, string>();
|
||
dictionary2.Add("type", "RealNameId");
|
||
dictionary2.Add("addTime", Tools.GenerateTimeStamp().ToString());
|
||
dictionary2.Add("value1", Tools.GetMD5_32(itunesLogin.account.Trim() + "123teluns"));
|
||
dictionary2.Add("value2", "1");
|
||
SqliteHelper.ExecuteInsert("itunes_db", dictionary2);
|
||
}
|
||
return CheckRealNameType.DonTneed;
|
||
}
|
||
return CheckRealNameType.Need;
|
||
}
|
||
return CheckRealNameType.Unknown;
|
||
}
|
||
|
||
public bool ActivateiTunesRemove(string account, string pwd, string userAgent, string guid, string idServerId, string actionUrl, string cookie, ref string msgReust)
|
||
{
|
||
if (overcheckPayment == null)
|
||
{
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, "正在协议内容..");
|
||
AppleItunesLogin appleItunesLogin = new AppleItunesLogin();
|
||
appleItunesLogin.Headers["User-Agent"] = userAgent;
|
||
appleItunesLogin.Guid = guid;
|
||
appleItunesLogin.cookis = new Dictionary<string, string>();
|
||
addCookle(appleItunesLogin, cookie);
|
||
string value = "143465-19,17";
|
||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||
dictionary.Add("X-Apple-Store-Front", value);
|
||
HttpResult itunesWebContext = getItunesWebContext(actionUrl, "", appleItunesLogin, dictionary, addToken: false);
|
||
if (itunesWebContext.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
string dataCountry = new Regex("data-country=\"([\\s\\S]*?)\"").Match(itunesWebContext.Html).Groups[1].Value;
|
||
string areaByCode = AppleUtlis.GetAreaByCode(dataCountry);
|
||
NationalList nationalList = (from c in new NationalData().getMation()
|
||
where c.payment.billingAddress.countryCode.ToUpper() == dataCountry.ToUpper()
|
||
select c).FirstOrDefault();
|
||
if (nationalList != null)
|
||
{
|
||
overcheckPayment = nationalList.payment;
|
||
}
|
||
else
|
||
{
|
||
action?.Invoke(base.notyKey, DisplyType.area, areaByCode);
|
||
Exception ex = new Exception(dataCountry + ",过检没有这个国家");
|
||
msgReust = "该国家ID暂不支持,请指定国家";
|
||
APIUtlis.ApiSeriveError(ex);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
msgReust = "加载失败 ,请指定国家";
|
||
}
|
||
}
|
||
if (overcheckPayment == null)
|
||
{
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, "该国家ID暂不支持.");
|
||
action?.Invoke(base.notyKey, DisplyType.error, "失败");
|
||
return false;
|
||
}
|
||
string postDataCountryChangen = GetPostDataCountryChangen(overcheckPayment);
|
||
Dictionary<string, object> dictionary2 = new Dictionary<string, object>
|
||
{
|
||
{ "account", account },
|
||
{ "editPostData", postDataCountryChangen },
|
||
{ "pwd", pwd },
|
||
{ "userAgent", userAgent },
|
||
{ "guid", guid },
|
||
{ "idServerId", idServerId },
|
||
{ "type", "IOvercheck" },
|
||
{ "gZip", "1" },
|
||
{ "ovcheckAgent", "overcheck" }
|
||
};
|
||
if (msgReust == "OvercheckAgent")
|
||
{
|
||
dictionary2["ovcheckAgent"] = "retry";
|
||
}
|
||
msgReust = "过检失败";
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, "正在过检.");
|
||
HttpResult httpResult = APIUtlis.serviceOtherSend(Tools.Toenjson(dictionary2));
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
dynamic val = Tools.Todejosn<object>(httpResult.Html);
|
||
if (val["Code"] == "0000")
|
||
{
|
||
int num = val["serverIndex"];
|
||
dictionary2.Add("serviceIndex", num);
|
||
dynamic datasetByString = GetDatasetByString(val["Data"].ToString());
|
||
dynamic val2 = Tools.Todejosn<object>(datasetByString);
|
||
string text = val2["code"];
|
||
if (text == "0001")
|
||
{
|
||
Thread.Sleep(3000);
|
||
}
|
||
int num2 = 0;
|
||
do
|
||
{
|
||
if (text == "0001" || text == "0002")
|
||
{
|
||
dictionary2["editPostData"] = "";
|
||
dictionary2["editPostData"] = "";
|
||
httpResult = APIUtlis.serviceOtherSend(Tools.Toenjson(dictionary2));
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
val = Tools.Todejosn<object>(httpResult.Html);
|
||
if (val["Code"] == "0000")
|
||
{
|
||
datasetByString = GetDatasetByString(val["Data"]);
|
||
val2 = Tools.Todejosn<object>(datasetByString);
|
||
text = val2["code"];
|
||
if (text != "0001" && text != "0002")
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
num2++;
|
||
int totalWidth = num2 % 6;
|
||
string text2 = "".PadLeft(totalWidth, '.');
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, "正在过检." + text2);
|
||
Thread.Sleep(1000);
|
||
}
|
||
while (taskState.isRun && num2 <= 90);
|
||
string arg = (msgReust = val2["msg"]);
|
||
if (text == "0000")
|
||
{
|
||
msgReust = text;
|
||
string areaByCode2 = AppleUtlis.GetAreaByCode(overcheckPayment.billingAddress.countryCode);
|
||
action?.Invoke(base.notyKey, DisplyType.area, areaByCode2);
|
||
action?.Invoke(base.notyKey, DisplyType.forbidden, "成功");
|
||
}
|
||
else
|
||
{
|
||
action?.Invoke(base.notyKey, DisplyType.error, "失败");
|
||
}
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, arg);
|
||
}
|
||
else
|
||
{
|
||
msgReust = "请求失败";
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, msgReust);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
msgReust = "请求失败";
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, msgReust);
|
||
}
|
||
return false;
|
||
}
|
||
|
||
public bool ActivateiTunes(string actionUrl, string cookie, string userAgent, string guid, string itunesSignature, ref string msgReust)
|
||
{
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, "正在过检查...");
|
||
AppleItunesLogin appleItunesLogin = new AppleItunesLogin();
|
||
appleItunesLogin.Headers["User-Agent"] = userAgent;
|
||
appleItunesLogin.Guid = guid;
|
||
appleItunesLogin.cookis = new Dictionary<string, string>();
|
||
addCookle(appleItunesLogin, cookie);
|
||
string value = "143465-19,17";
|
||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||
dictionary.Add("X-Apple-Store-Front", value);
|
||
msgReust = "过检失败..";
|
||
HttpResult itunesWebContext = getItunesWebContext(actionUrl, "", appleItunesLogin, dictionary, addToken: false);
|
||
if (itunesWebContext.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
string dataCountry = new Regex("data-country=\"([\\s\\S]*?)\"").Match(itunesWebContext.Html).Groups[1].Value;
|
||
string areaByCode = AppleUtlis.GetAreaByCode(dataCountry);
|
||
appleItunesLogin.Area = areaByCode;
|
||
if (overcheckPayment == null)
|
||
{
|
||
NationalList nationalList = (from c in new NationalData().getMation()
|
||
where c.payment.billingAddress.countryCode.ToUpper() == dataCountry.ToUpper()
|
||
select c).FirstOrDefault();
|
||
if (nationalList == null)
|
||
{
|
||
APIUtlis.ApiSeriveError(new Exception(dataCountry + ",过检没有这个国家"));
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, "该国家ID暂不支持,请指定国家");
|
||
action?.Invoke(base.notyKey, DisplyType.error, "失败");
|
||
action?.Invoke(base.notyKey, DisplyType.area, appleItunesLogin.Area);
|
||
return false;
|
||
}
|
||
overcheckPayment = nationalList.payment;
|
||
}
|
||
Uri uri = new Uri(actionUrl);
|
||
string text = uri.Scheme + "://" + uri.Host;
|
||
string text2 = text + "/WebObjects/MZFinance.woa/wo/2.2.1.1.1.3.0.5.1.1.7.1.1.7";
|
||
itunesWebContext = getItunesWebContext(text2, "", appleItunesLogin, dictionary, addToken: false);
|
||
if (itunesWebContext.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
string value2 = new Regex("mzPageUUID([\\s\\S]*?)>").Match(itunesWebContext.Html).Groups[1].Value;
|
||
string value3 = new Regex("value='([\\s\\S]*?)'").Match(value2).Groups[1].Value;
|
||
if (!string.IsNullOrEmpty(value3))
|
||
{
|
||
string postData = "2.1.1.1.3.0.5.1.1.7.3.7.1=2.1.1.1.3.0.5.1.1.7.3.7.1&mzPageUUID=" + Tools.ToUrlEncode(value3) + "&machineGUID=" + appleItunesLogin.Guid + "&xAppleActionSignature=" + Tools.ToUrlEncode(itunesSignature);
|
||
string url = text + "/WebObjects/MZFinance.woa/wo/4.2.1.1.1.3.0.5.1.1.7.3.7";
|
||
HttpResult httpResult = postUrlencodedItunesWebContext(url, postData, text2, appleItunesLogin, dictionary);
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
if (httpResult.Html.Contains("edit-account"))
|
||
{
|
||
msgReust = "账号资料未补全..";
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, msgReust);
|
||
return false;
|
||
}
|
||
action?.Invoke(base.notyKey, DisplyType.area, appleItunesLogin.Area);
|
||
string value4 = new Regex("lastName([\\s\\S]*?)>").Match(httpResult.Html).Groups[1].Value;
|
||
string value5 = new Regex("firstName([\\s\\S]*?)>").Match(httpResult.Html).Groups[1].Value;
|
||
string value6 = new Regex("value=\"([\\s\\S]*?)\"").Match(value4).Groups[1].Value;
|
||
string value7 = new Regex("value=\"([\\s\\S]*?)\"").Match(value5).Groups[1].Value;
|
||
if (!string.IsNullOrEmpty(value7))
|
||
{
|
||
string.IsNullOrEmpty(value6);
|
||
}
|
||
string postDataCountryChangen = GetPostDataCountryChangen(overcheckPayment);
|
||
string randomTel = Tools.getRandomTel();
|
||
string text3 = Tools.ToUrlEncode(value6 + "," + value7);
|
||
postData = "2.0.1.1.3.0.5.1.1.7.1.1.0.5.13.1.5.5=CN&2.0.1.1.3.0.5.1.1.7.1.1.0.5.13.1.5.7=%E6%9B%B4%E6%94%B9&credit-card-type=&sp=&res=&2.0.1.1.3.0.5.1.1.7.1.1.0.5.19.1.0.0.0.15.7=&card-type-id=0&2.0.1.1.3.0.5.1.1.7.1.1.0.5.25.1.3.1.3.2.3=&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.1.3.1=" + Tools.ToUrlEncode(value6) + "&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.1.3.3=" + Tools.ToUrlEncode(value7) + "&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.5.13.1=&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.5.13.3=&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.5.13.5=&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.5.13.7=&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.5.13.9=&state=WONoSelectionString&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.5.13.17=&machineGUID=" + appleItunesLogin.Guid + "&mzPageUUID=" + Tools.ToUrlEncode(value3) + "&xAppleActionSignature=" + Tools.ToUrlEncode(itunesSignature) + "&longName=" + text3;
|
||
url = text + "/WebObjects/MZFinance.woa/wo/5.2.0.1.1.3.0.5.1.1.7.1";
|
||
httpResult = postUrlencodedItunesWebContext(url, postData, url, appleItunesLogin, dictionary);
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, "正在同意协议...");
|
||
url = text + "/WebObjects/MZFinance.woa/wo/6.2.1.1.1.3.0.5.1.1.7.3.7";
|
||
postData = "2.1.1.1.3.0.5.1.1.7.3.7.1=2.1.1.1.3.0.5.1.1.7.3.7.1&mzPageUUID=" + Tools.ToUrlEncode(value3) + "&machineGUID=" + appleItunesLogin.Guid + "&xAppleActionSignature=" + Tools.ToUrlEncode(itunesSignature);
|
||
httpResult = postUrlencodedItunesWebContext(url, postData, url, appleItunesLogin, dictionary);
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
int num = 7;
|
||
url = text + "/WebObjects/MZFinance.woa/wo/" + 7 + ".2.0.1.1.3.0.5.1.1.7.1";
|
||
postData = "2.0.1.1.3.0.5.1.1.7.1.1.0.5.13.1.5.5=CN&credit-card-type=&sp=&res=&None=%E6%97%A0&email-regex=%5E%5BA-Za-z0-9._%25%2B-%5D%2B%40&phone-regex=%5E%5B0-9-%5D%7B10%2C30%7D%24&2.0.1.1.3.0.5.1.1.7.1.1.0.5.19.1.0.0.0.15.1.5.3=&2.0.1.1.3.0.5.1.1.7.1.1.0.5.19.1.0.0.0.15.1.5.7=&2.0.1.1.3.0.5.1.1.7.1.1.0.5.19.1.0.0.0.15.5.1=0&2.0.1.1.3.0.5.1.1.7.1.1.0.5.19.1.0.0.0.15.7=&card-type-id=0&2.0.1.1.3.0.5.1.1.7.1.1.0.5.25.1.3.1.3.2.3=&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.1.3.1=Ruspi&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.1.3.3=Lorenzo&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.5.13.1=&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.5.13.3=&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.5.13.5=&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.5.13.7=&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.5.13.9=&state=WONoSelectionString&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.5.13.17=&machineGUID=" + appleItunesLogin.Guid + "&mzPageUUID=" + Tools.ToUrlEncode(value3) + "&xAppleActionSignature=" + itunesSignature + "&longName=Ruspi%2CLorenzo";
|
||
httpResult = postUrlencodedItunesWebContext(url, postData, url, appleItunesLogin, dictionary);
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
num++;
|
||
url = text + "/WebObjects/MZFinance.woa/wo/" + num + ".2.0.1.1.3.0.5.1.1.7.1";
|
||
string text4 = "湖北省荆门市";
|
||
string text5 = "448000";
|
||
for (int i = 0; i < 10; i++)
|
||
{
|
||
string[] array = Tools.GetAddress().Split('\t');
|
||
if (array.Length >= 2)
|
||
{
|
||
text4 = array[0];
|
||
text5 = array[1];
|
||
break;
|
||
}
|
||
}
|
||
Dictionary<string, int> obj = new Dictionary<string, int>
|
||
{
|
||
{ "安徽", 0 },
|
||
{ "北京", 1 },
|
||
{ "重庆", 2 },
|
||
{ "福建", 3 },
|
||
{ "甘肃", 4 },
|
||
{ "广东", 5 },
|
||
{ "广西", 6 },
|
||
{ "贵州", 7 },
|
||
{ "海南", 8 },
|
||
{ "河北", 9 },
|
||
{ "黑龙江", 10 },
|
||
{ "河南", 11 },
|
||
{ "湖北", 12 },
|
||
{ "湖南", 13 },
|
||
{ "江苏", 14 },
|
||
{ "江西", 15 },
|
||
{ "吉林", 16 },
|
||
{ "辽宁", 17 },
|
||
{ "内蒙古", 18 },
|
||
{ "宁夏", 19 },
|
||
{ "青海", 20 },
|
||
{ "陕西", 21 },
|
||
{ "山东", 22 },
|
||
{ "上海", 23 },
|
||
{ "山西", 24 },
|
||
{ "四川", 25 },
|
||
{ "天津", 26 },
|
||
{ "新疆", 27 },
|
||
{ "西藏", 28 },
|
||
{ "云南", 29 },
|
||
{ "浙江", 30 }
|
||
};
|
||
string text6 = "6";
|
||
foreach (KeyValuePair<string, int> item in obj)
|
||
{
|
||
if (text4.Contains(item.Key))
|
||
{
|
||
text6 = item.Value.ToString();
|
||
}
|
||
}
|
||
string value8 = Tools.GenerateRandomLetter(new Random().Next(4, 7));
|
||
string value9 = Tools.GenerateRandomLetter(new Random(Guid.NewGuid().GetHashCode()).Next(2, 8));
|
||
postData = "2.0.1.1.3.0.5.1.1.7.1.1.0.5.13.1.5.5=CN&credit-card-type=&sp=&res=&2.0.1.1.3.0.5.1.1.7.1.1.0.5.19.1.0.1.0.15.7=" + randomTel + "&card-type-id=0&2.0.1.1.3.0.5.1.1.7.1.1.0.5.25.1.3.1.3.2.3=&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.1.3.1=" + Tools.ToUrlEncode(value6) + "&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.1.3.3=" + Tools.ToUrlEncode(value7) + "&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.5.13.1=1-" + new Random().Next(5, 100) + "-2&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.5.13.3=" + Tools.ToUrlEncode(value9) + "&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.5.13.5=" + Tools.ToUrlEncode(value8) + "&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.5.13.7=" + Tools.ToUrlEncode(text4) + "&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.5.13.9=" + text5 + "&state=" + text6 + "&2.0.1.1.3.0.5.1.1.7.1.1.0.5.27.5.5.13.17=" + randomTel + "&2.0.1.1.3.0.5.1.1.7.1.7.1=%E7%BB%A7%E7%BB%AD&machineGUID=" + appleItunesLogin.Guid + "&mzPageUUID=" + Tools.ToUrlEncode(value3) + "&xAppleActionSignature=" + Tools.ToUrlEncode(itunesSignature) + "&longName=" + text3;
|
||
httpResult = postUrlencodedItunesWebContext(url, postData, url, appleItunesLogin, dictionary);
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
num++;
|
||
string arg = "";
|
||
string keyValue = GetKeyValue("<key>passwordToken</key>", "<string>", "</string>", httpResult.Html);
|
||
string keyValue2 = GetKeyValue("<key>dsPersonId</key>", "<string>", "</string>", httpResult.Html);
|
||
if (!string.IsNullOrEmpty(keyValue))
|
||
{
|
||
appleItunesLogin.xtoken = keyValue;
|
||
appleItunesLogin.dsis = keyValue2;
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, "正在保存账单地址信息..");
|
||
if (overcheckPayment.billingAddress.countryCode.ToLower() == "chn")
|
||
{
|
||
appleItunesLogin.Area = AppleUtlis.GetAreaByCode(overcheckPayment.billingAddress.countryCode);
|
||
action?.Invoke(base.notyKey, DisplyType.area, appleItunesLogin.Area);
|
||
msgReust = "0000";
|
||
arg = "过检成功";
|
||
}
|
||
else
|
||
{
|
||
HttpResult httpResult2 = postUrlencodedItunesWebContext(text + "/WebObjects/MZFinance.woa/wa/editBillingInfoSrv", postDataCountryChangen, "https://finance-app.itunes.apple.com/account/storefront/edit/billing-info", appleItunesLogin, dictionary);
|
||
if (httpResult2.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
Dictionary<string, object> dictionary2 = (dynamic)Tools.Todejosn<object>(httpResult2.Html);
|
||
if ((int)(dynamic)dictionary2["status"] == 0)
|
||
{
|
||
appleItunesLogin.Area = AppleUtlis.GetAreaByCode(overcheckPayment.billingAddress.countryCode);
|
||
action?.Invoke(base.notyKey, DisplyType.area, appleItunesLogin.Area);
|
||
msgReust = "0000";
|
||
arg = "过检成功";
|
||
}
|
||
else if (httpResult2.Html.Contains("MZCommerce.AccountDisabled"))
|
||
{
|
||
arg = "保存账单信息失败:账号已被禁用";
|
||
}
|
||
else if (httpResult2.Html.Contains("localizedMessage"))
|
||
{
|
||
arg = "保存账单信息失败:" + ((dynamic)dictionary2["result"])["validationResults"][0]["localizedMessage"];
|
||
}
|
||
else
|
||
{
|
||
try
|
||
{
|
||
if (httpResult2.Html.Contains("errorString") && httpResult2.Html.Contains("validationResults"))
|
||
{
|
||
arg = "保存账单信息失败:" + ((dynamic)dictionary2["result"])["validationResults"][0]["errorString"];
|
||
}
|
||
else if (httpResult2.Html.Contains("userPresentableErrorMessage"))
|
||
{
|
||
arg = "保存账单信息失败:" + (dynamic)dictionary2["userPresentableErrorMessage"];
|
||
}
|
||
else if (httpResult2.Html.Contains("errorString"))
|
||
{
|
||
arg = "保存账单失败:" + ((dynamic)dictionary2["result"])[0]["errorString"];
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
APIUtlis.ApiSeriveError(ex);
|
||
arg = "出错误了:" + httpResult2.Html;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
arg = "保存账单信息请求错误:状态 (" + (int)httpResult2.StatusCode + ")";
|
||
}
|
||
}
|
||
action?.Invoke(base.notyKey, DisplyType.forbidden, "成功");
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, arg);
|
||
return true;
|
||
}
|
||
string keyValue3 = GetKeyValue("\"error\"", ">", "<", httpResult.Html);
|
||
if (!string.IsNullOrEmpty(keyValue3))
|
||
{
|
||
msgReust = keyValue3;
|
||
}
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, msgReust);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
action?.Invoke(base.notyKey, DisplyType.error, "失败");
|
||
return false;
|
||
}
|
||
|
||
public bool AnswerQuestion(string url, string refUrl, AppleItunesLogin itunesLogin, string answer1, string answer2, string answer3)
|
||
{
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, "正在填写密保...");
|
||
HttpResult itunesWebContext = getItunesWebContext(url, refUrl, itunesLogin, null, addToken: true);
|
||
if (itunesWebContext.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
string html = itunesWebContext.Html;
|
||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||
if (html.Contains("answer1"))
|
||
{
|
||
Match match = Regex.Match(html, "(?<=\\<input.*id=\\\"answer1\\\".*name=\\\").*?(?=\\\")");
|
||
dictionary.Add(match.Value, HttpUtility.UrlEncode(answer1));
|
||
}
|
||
if (html.Contains("answer2"))
|
||
{
|
||
Match match2 = Regex.Match(html, "(?<=\\<input.*id=\\\"answer2\\\".*name=\\\").*?(?=\\\")");
|
||
dictionary.Add(match2.Value, HttpUtility.UrlEncode(answer2));
|
||
}
|
||
if (html.Contains("answer3"))
|
||
{
|
||
Match match3 = Regex.Match(html, "(?<=\\<input.*id=\\\"answer3\\\".*name=\\\").*?(?=\\\")");
|
||
dictionary.Add(match3.Value, HttpUtility.UrlEncode(answer3));
|
||
}
|
||
if (html.Contains("continue ok"))
|
||
{
|
||
Match match4 = Regex.Match(html, "(?<=\\<input.*class=\\\"continue ok\\\".*name=\\\").*?(?=\\\")");
|
||
Match match5 = Regex.Match(html, "(?<=\\<input.*class=\\\"continue ok\\\".*value=\\\").*?(?=\\\")");
|
||
dictionary.Add(match4.Value, match5.Value);
|
||
}
|
||
if (html.Contains("<form"))
|
||
{
|
||
Match match6 = Regex.Match(html, "(?<=\\<form.*action=\\\").*?(?=\\\")");
|
||
string url2 = string.Format("https://p{0}-buy.itunes.apple.com" + match6.Value, itunesLogin.ServerId);
|
||
Dictionary<string, string> dictionary2 = new Dictionary<string, string>();
|
||
dictionary2.Add("X-Apple-Store-Front", itunesLogin.software);
|
||
string text = "";
|
||
foreach (KeyValuePair<string, string> item in dictionary)
|
||
{
|
||
text = text + item.Key + "=" + item.Value + "&";
|
||
}
|
||
HttpResult httpResult = postUrlencodedItunesWebContext(url2, text, refUrl, itunesLogin, dictionary2);
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
if (httpResult.Html.Contains("Security"))
|
||
{
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, "密保错误...");
|
||
return false;
|
||
}
|
||
if (httpResult.Html.Contains("GoBack"))
|
||
{
|
||
if (AppSysConfig.ReddemVerifyGuid.ContainsKey(itunesLogin.account))
|
||
{
|
||
AppSysConfig.ReddemVerifyGuid[itunesLogin.account] = itunesLogin.Guid;
|
||
}
|
||
else
|
||
{
|
||
AppSysConfig.ReddemVerifyGuid.TryAdd(itunesLogin.account, itunesLogin.Guid);
|
||
}
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, "密保验证成功...");
|
||
return true;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
public ReddemeState serverReddeme(AppleItunesLogin itunesLogin, string code, ref string msg, ref string errorMessageKey, int serverIndex)
|
||
{
|
||
string text = "143465-19,12";
|
||
text = AppSysConfig.getConfig("ReddemeStoreFrontType") switch
|
||
{
|
||
"3" => itunesLogin.software,
|
||
"2" => itunesLogin.software.Split('-')[0] + "-19," + itunesLogin.software.Split(',')[1],
|
||
"1" => "143465-19,12",
|
||
_ => "143465-19,12",
|
||
};
|
||
string config = AppSysConfig.getConfig("getTermsByCountryAndTypeSrv");
|
||
HttpResult httpResult = APIUtlis.serviceSend(Tools.Toenjson(new Dictionary<string, object>
|
||
{
|
||
{ "appleId", itunesLogin.account },
|
||
{ "applePwd", itunesLogin.pwd },
|
||
{ "code", code },
|
||
{
|
||
"reddemQts",
|
||
Tools.ToUrlEncode(itunesLogin.reddemQts)
|
||
},
|
||
{ "appleStoreFront", text },
|
||
{
|
||
"termsCheckSrv",
|
||
Tools.ToUrlEncode(config)
|
||
},
|
||
{ "guid", itunesLogin.Guid },
|
||
{ "serviceIndex", serverIndex },
|
||
{ "type", "IReddem" }
|
||
}));
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
dynamic val = Tools.Todejosn<object>(httpResult.Html);
|
||
if (val["Code"] == "0000")
|
||
{
|
||
string text2 = val["Data"];
|
||
if (!string.IsNullOrEmpty(text2))
|
||
{
|
||
ServiceReddemModel serviceReddemModel = Tools.Todejosn<ServiceReddemModel>(text2);
|
||
int status = serviceReddemModel.status;
|
||
_ = serviceReddemModel.code;
|
||
string msg2 = serviceReddemModel.msg;
|
||
if (!string.IsNullOrEmpty(msg2))
|
||
{
|
||
msg = msg2;
|
||
}
|
||
else
|
||
{
|
||
msg = "状态未知,请重试";
|
||
}
|
||
if (status == 0)
|
||
{
|
||
return ReddemeState.valid;
|
||
}
|
||
if (serviceReddemModel.errorMessageKey != null)
|
||
{
|
||
errorMessageKey = serviceReddemModel.errorMessageKey;
|
||
}
|
||
ReddemeState result = ReddemeState.Unknown;
|
||
string[] array = AppSysConfig.getConfig("ReddemCardKeywordValid").Split(',');
|
||
foreach (string value in array)
|
||
{
|
||
if (!string.IsNullOrEmpty(value) && errorMessageKey.Contains(value))
|
||
{
|
||
result = ReddemeState.valid;
|
||
break;
|
||
}
|
||
}
|
||
array = AppSysConfig.getConfig("ReddemCardKeywordLose").Split(',');
|
||
foreach (string value2 in array)
|
||
{
|
||
if (!string.IsNullOrEmpty(value2) && errorMessageKey.Contains(value2))
|
||
{
|
||
result = ReddemeState.lose;
|
||
break;
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
msg = "网络请求失败,状态未知,请重试#1";
|
||
}
|
||
else
|
||
{
|
||
msg = "网络请求失败,状态未知,请重试";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
msg = "网络请求失败";
|
||
}
|
||
return ReddemeState.Unknown;
|
||
}
|
||
|
||
public void GetCodeInfoSrv(AppleItunesLogin itunesLogin, bool _OpenVpn, string code, ref string msg, bool accepted = false)
|
||
{
|
||
openVpn = _OpenVpn;
|
||
base.appleId = code;
|
||
string text = "https://p" + itunesLogin.ServerId + "-buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/getCodeInfoSrv?code=" + code + "&guid=" + itunesLogin.Guid;
|
||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||
switch (AppSysConfig.getConfig("ReddemeStoreFrontType"))
|
||
{
|
||
default:
|
||
dictionary.Add("X-Apple-Store-Front", "143465-19,12");
|
||
break;
|
||
case "3":
|
||
dictionary.Add("X-Apple-Store-Front", itunesLogin.software);
|
||
break;
|
||
case "2":
|
||
dictionary.Add("X-Apple-Store-Front", itunesLogin.software.Split('-')[0] + "-19," + itunesLogin.software.Split(',')[1]);
|
||
break;
|
||
case "1":
|
||
dictionary.Add("X-Apple-Store-Front", "143465-19,12");
|
||
break;
|
||
}
|
||
getItunesWebContext(text, text, itunesLogin, dictionary, addToken: true);
|
||
}
|
||
|
||
public ReddemeState reddeme(AppleItunesLogin itunesLogin, bool _OpenVpn, string code, string _notiKey, ref string msg, ref string errorMessageKey, bool accepted = false, Func<string, string, int, string> actGetCode = null)
|
||
{
|
||
openVpn = _OpenVpn;
|
||
base.appleId = _notiKey;
|
||
string text = "https://p" + itunesLogin.ServerId + "-buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/com.apple.jingle.app.finance.DirectAction/redeemCode?cl=iTunes&pg=Music";
|
||
string text2 = string.Format("attemptCount=1&cameraReCOGnizedCode=false&cl=iTunes&code={0}&dsPersonId=" + itunesLogin.dsis.Trim() + "&guid={1}&has4GBLimit=false&kbsync={2}&pg=Music&response-content-type=application/json", code.Replace(" ", "").Trim(), itunesLogin.Guid, "");
|
||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||
dictionary.Add("noticeActKey", _notiKey);
|
||
switch (AppSysConfig.getConfig("ReddemeStoreFrontType"))
|
||
{
|
||
default:
|
||
dictionary.Add("X-Apple-Store-Front", "143465-19,12");
|
||
break;
|
||
case "3":
|
||
dictionary.Add("X-Apple-Store-Front", itunesLogin.software);
|
||
break;
|
||
case "2":
|
||
dictionary.Add("X-Apple-Store-Front", itunesLogin.software.Split('-')[0] + "-19," + itunesLogin.software.Split(',')[1]);
|
||
break;
|
||
case "1":
|
||
dictionary.Add("X-Apple-Store-Front", "143465-19,12");
|
||
break;
|
||
}
|
||
if (code.Replace(" ", "").Trim().Length == 12)
|
||
{
|
||
text2 += "&hasConfirmAutoRenew=true";
|
||
if (itunesLogin.Headers["User-Agent"].ToString() != "AppStore/2.0 iOS/7.0.4 model/iPhone6,2 (6; dt:90)")
|
||
{
|
||
itunesLogin.oldUserAgent = itunesLogin.Headers["User-Agent"].ToString();
|
||
}
|
||
itunesLogin.Headers["User-Agent"] = "AppStore/2.0 iOS/7.0.4 model/iPhone6,2 (6; dt:90)";
|
||
}
|
||
else if (!string.IsNullOrEmpty(itunesLogin.oldUserAgent))
|
||
{
|
||
itunesLogin.Headers["User-Agent"] = itunesLogin.oldUserAgent;
|
||
}
|
||
string url = "https://p" + itunesLogin.ServerId + "-buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/redeemCodeSrv";
|
||
HttpResult httpResult = postItunesWebContext(url, text2, text, itunesLogin, dictionary, isContityNeet: false);
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
if (!string.IsNullOrEmpty(httpResult.Html))
|
||
{
|
||
if (httpResult.Html.Contains("MZFinance.RedeemCodeSrvLoginRequired"))
|
||
{
|
||
return ReddemeState.doLogin;
|
||
}
|
||
Dictionary<string, object> dictionary2 = (dynamic)Tools.Todejosn<object>(httpResult.Html);
|
||
int num = (dynamic)dictionary2["status"];
|
||
if (num == 0)
|
||
{
|
||
msg = "兑换成功";
|
||
string text3 = "";
|
||
if (dictionary2.ContainsKey("salables"))
|
||
{
|
||
try
|
||
{
|
||
object[] array = (dynamic)dictionary2["salables"];
|
||
for (int i = 0; i < array.Length; i++)
|
||
{
|
||
Dictionary<string, object> dictionary3 = (Dictionary<string, object>)(dynamic)array[i];
|
||
if (dictionary3.ContainsKey("salableName"))
|
||
{
|
||
text3 = (string)(text3 + (", " + (dynamic)dictionary3["salableName"] + " "));
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
APIUtlis.ApiSeriveError(ex);
|
||
}
|
||
}
|
||
if (dictionary2.ContainsKey("redeemedCredit") && ((Dictionary<string, object>)(dynamic)dictionary2["redeemedCredit"]).ContainsKey("totalCredit"))
|
||
{
|
||
string text4 = ((dynamic)dictionary2["redeemedCredit"])["totalCredit"];
|
||
if (string.IsNullOrEmpty(text4) && !string.IsNullOrEmpty(text3))
|
||
{
|
||
msg += text3;
|
||
}
|
||
else
|
||
{
|
||
msg = msg + ",加载金额:" + text4;
|
||
}
|
||
}
|
||
if (dictionary2.ContainsKey("creditDisplay"))
|
||
{
|
||
msg = (string)(msg + (",ID总金额:" + (dynamic)dictionary2["creditDisplay"]));
|
||
}
|
||
return ReddemeState.valid;
|
||
}
|
||
msg = "兑换失败,原因未知";
|
||
if (num == -1)
|
||
{
|
||
if (dictionary2.ContainsKey("userPresentableErrorMessage"))
|
||
{
|
||
msg = (dynamic)dictionary2["userPresentableErrorMessage"];
|
||
if (string.IsNullOrEmpty(msg))
|
||
{
|
||
msg = new Regex("\"message\":\"([\\s\\S]*?)\"").Match(httpResult.Html).Groups[1].Value;
|
||
}
|
||
}
|
||
msg = AppleUtlis.Html2Text(msg, isEmorp: false);
|
||
if (dictionary2.ContainsKey("errorMessageKey"))
|
||
{
|
||
errorMessageKey = (dynamic)dictionary2["errorMessageKey"];
|
||
if (errorMessageKey == "MZCommerce.StaleBillingInfo" && actGetCode != null)
|
||
{
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, "需要更新账单,正在加载支付..");
|
||
itunesLogin.Headers["User-Agent"] = itunesLogin.oldUserAgent;
|
||
PaymentList paymentInfos = getPaymentInfos(itunesLogin);
|
||
if (paymentInfos != null)
|
||
{
|
||
PaymentList.Paymentinfo[] array2 = paymentInfos?.data?.attributes?.paymentInfos;
|
||
foreach (PaymentList.Paymentinfo paymentinfo in array2)
|
||
{
|
||
if (paymentinfo == null || !paymentinfo.requiresPSD2Check)
|
||
{
|
||
continue;
|
||
}
|
||
string text5 = "--";
|
||
string arg = "如需激活付款方式,请验证安全码。";
|
||
if (paymentinfo.last4CCDigits != null)
|
||
{
|
||
text5 = paymentinfo.last4CCDigits;
|
||
}
|
||
PaymentList.ValidationErrors[] validationErrors = paymentinfo.validationErrors;
|
||
if (validationErrors != null && validationErrors.Length != 0 && paymentinfo.validationErrors[0].error != null)
|
||
{
|
||
arg = paymentinfo.validationErrors[0].error;
|
||
}
|
||
string text6 = actGetCode?.Invoke(arg, "卡尾号:" + text5 + ",账号Id: " + itunesLogin.account, 1);
|
||
if (!string.IsNullOrEmpty(text6))
|
||
{
|
||
string paymentId = paymentinfo.paymentId;
|
||
string creditCardExpirationMonth = "••";
|
||
string creditCardExpirationYear = "••••";
|
||
if (paymentinfo.creditCardExpirationMonth != null)
|
||
{
|
||
creditCardExpirationMonth = paymentinfo.creditCardExpirationMonth;
|
||
}
|
||
if (paymentinfo.creditCardExpirationYear != null)
|
||
{
|
||
creditCardExpirationYear = paymentinfo.creditCardExpirationYear;
|
||
}
|
||
if (PaymentChallengeInitiate(paymentId, text6, creditCardExpirationMonth, creditCardExpirationYear, itunesLogin, ref msg))
|
||
{
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, "激活成功完成,正在重新兑换..");
|
||
accepted = true;
|
||
return reddeme(itunesLogin, _OpenVpn, code, _notiKey, ref msg, ref errorMessageKey, accepted: true);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
ReddemeState result = ReddemeState.Unknown;
|
||
string[] array3 = AppSysConfig.getConfig("ReddemCardKeywordValid").Split(',');
|
||
foreach (string value in array3)
|
||
{
|
||
if (!string.IsNullOrEmpty(value) && httpResult.Html.Contains(value))
|
||
{
|
||
result = ReddemeState.valid;
|
||
break;
|
||
}
|
||
}
|
||
array3 = AppSysConfig.getConfig("ReddemCardKeywordLose").Split(',');
|
||
foreach (string value2 in array3)
|
||
{
|
||
if (!string.IsNullOrEmpty(value2) && httpResult.Html.Contains(value2))
|
||
{
|
||
result = ReddemeState.lose;
|
||
break;
|
||
}
|
||
}
|
||
try
|
||
{
|
||
if (dictionary2.ContainsKey("errorNumber") && (int)(dynamic)dictionary2["errorNumber"] == 3079 && !string.IsNullOrEmpty(itunesLogin.reddemQts))
|
||
{
|
||
string url2 = ((dynamic)dictionary2["dialog"])["okButtonAction"]["url"];
|
||
string[] array4 = itunesLogin.reddemQts.Split(',');
|
||
if (array4.Length == 3)
|
||
{
|
||
bool flag = true;
|
||
lock (objReddemLock)
|
||
{
|
||
if (!AppSysConfig.ReddemVerifyGuid.ContainsKey(itunesLogin.account))
|
||
{
|
||
flag = AnswerQuestion(url2, text, itunesLogin, array4[0], array4[1], array4[2]);
|
||
}
|
||
else if (AppSysConfig.ReddemVerifyGuid[itunesLogin.account] != itunesLogin.Guid)
|
||
{
|
||
flag = AnswerQuestion(url2, text, itunesLogin, array4[0], array4[1], array4[2]);
|
||
}
|
||
}
|
||
if (flag)
|
||
{
|
||
return reddeme(itunesLogin, _OpenVpn, code, _notiKey, ref msg, ref errorMessageKey, accepted);
|
||
}
|
||
msg = "密保验证失败..";
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex2)
|
||
{
|
||
APIUtlis.ApiSeriveError(ex2);
|
||
}
|
||
string config = AppSysConfig.getConfig("getTermsByCountryAndTypeSrv");
|
||
if (msg.Contains(config) && !accepted)
|
||
{
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, "正在更新条款...");
|
||
itunesLogin.Headers["User-Agent"] = itunesLogin.oldUserAgent;
|
||
string text7 = "https://p" + itunesLogin.ServerId + "-buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/getTermsByCountryAndTypeSrv?cc=" + itunesLogin.AreaCode + "&termsType=MZStore.NewTermsAndConditionsStatement";
|
||
HttpResult itunesWebContext = getItunesWebContext(text7, "", itunesLogin, null, addToken: true);
|
||
if (itunesWebContext.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
string token = AppleNetworkBase.GetToken(itunesWebContext.Html, "termsVersionId\":", ",");
|
||
string postData = "{\"id\":\"" + itunesLogin.dsis + "\",\"accepted\":" + token + "}";
|
||
if (!string.IsNullOrEmpty(token))
|
||
{
|
||
string url3 = "https://p" + itunesLogin.ServerId + "-buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/termsCheckSrv";
|
||
Dictionary<string, string> dictionary4 = new Dictionary<string, string>();
|
||
dictionary4.Add("X-Apple-Store-Front", itunesLogin.software);
|
||
HttpResult httpResult2 = postUrlencodedItunesWebContext(url3, postData, text7, itunesLogin, dictionary4);
|
||
if (httpResult2.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
if (httpResult2.Html.Contains("status"))
|
||
{
|
||
accepted = true;
|
||
return reddeme(itunesLogin, _OpenVpn, code, _notiKey, ref msg, ref errorMessageKey, accepted: true);
|
||
}
|
||
msg = "[3]" + msg;
|
||
}
|
||
else
|
||
{
|
||
msg = "[2]" + msg;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
msg = "[4]" + msg;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
msg = "[1]" + msg;
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
return ReddemeState.Unknown;
|
||
}
|
||
msg = "兑换暂不可用,请一分钟后在试一次";
|
||
}
|
||
else
|
||
{
|
||
msg = "网络连接失败,状态未知 (" + (int)httpResult.StatusCode + ")";
|
||
}
|
||
return ReddemeState.Unknown;
|
||
}
|
||
|
||
public AppleItunesLogin getItunesLogin(AppleAcount account, int type, Action<string, DisplyType, string> _action, int isStore = 0)
|
||
{
|
||
_action?.Invoke(base.notyKey, DisplyType.xinxi, "正在处理");
|
||
HttpResult isLogin = APIUtlis.getIsLogin(type);
|
||
if (isLogin.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
dynamic val = Tools.Todejosn<object>(isLogin.Html);
|
||
if (val["Code"] == "0000")
|
||
{
|
||
if (val["Data"]["integral"] >= AppSysConfig.getTypeById(type).consNum)
|
||
{
|
||
_action?.Invoke(base.notyKey, DisplyType.chongzhi, "");
|
||
string msgReust = "";
|
||
AppleItunesLogin appleItunesLogin = null;
|
||
appleItunesLogin = ((!AppSysConfig.iTunesisRemoteLogin) ? appleLogin(account.appleId, account.applePwd + (account.isDoubleModl ? account.DoublePwd : ""), 1, ref msgReust, out var _) : remoteAppleLogin(account.appleId, account.applePwd + (account.isDoubleModl ? account.DoublePwd : ""), ref msgReust, isStore));
|
||
if (appleItunesLogin != null)
|
||
{
|
||
if (account.isDoubleModl)
|
||
{
|
||
appleItunesLogin.pwd = account.applePwd;
|
||
}
|
||
return appleItunesLogin;
|
||
}
|
||
_action?.Invoke(base.notyKey, DisplyType.xinxi, msgReust);
|
||
}
|
||
else
|
||
{
|
||
_action?.Invoke(base.notyKey, DisplyType.xinxi, "点数不足,请联系客服充值");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
_action?.Invoke(base.notyKey, DisplyType.xinxi, val["Message"]);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
_action?.Invoke(base.notyKey, DisplyType.xinxi, "网络请求失败");
|
||
}
|
||
return null;
|
||
}
|
||
|
||
public bool addOrEditBillingInfoSrv(AppleItunesLogin itunesLogin, string creditCardNumber, string creditCardExpirationYear, string creditCardExpirationMonth, string creditVerificationNumber)
|
||
{
|
||
action?.Invoke(itunesLogin.account, DisplyType.xinxi, "正在查询支付方式");
|
||
PaymentList paymentInfos = getPaymentInfos(itunesLogin);
|
||
if (paymentInfos != null)
|
||
{
|
||
AddPaymentCardType cardType = GetCardType(itunesLogin, creditCardNumber);
|
||
if (cardType != null)
|
||
{
|
||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||
dictionary.Add("X-Apple-Store-Front", itunesLogin.software.Split('-')[0] + "-19," + itunesLogin.software.Split(',')[1]);
|
||
string url = "https://p" + itunesLogin.ServerId + "-buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/addOrEditBillingInfoSrv";
|
||
string referer = "https://finance-app.itunes.apple.com/account/manage-payments/add-payment";
|
||
object obj;
|
||
if (paymentInfos == null)
|
||
{
|
||
obj = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Data data = paymentInfos.data;
|
||
if (data == null)
|
||
{
|
||
obj = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Attributes attributes = data.attributes;
|
||
obj = ((attributes == null) ? null : attributes.paymentInfos[0]?.billingAddress?.billingFirstName);
|
||
}
|
||
}
|
||
string value = (string)obj;
|
||
object obj2;
|
||
if (paymentInfos == null)
|
||
{
|
||
obj2 = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Data data2 = paymentInfos.data;
|
||
if (data2 == null)
|
||
{
|
||
obj2 = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Attributes attributes2 = data2.attributes;
|
||
obj2 = ((attributes2 == null) ? null : attributes2.paymentInfos[0]?.billingAddress?.billingLastName);
|
||
}
|
||
}
|
||
string value2 = (string)obj2;
|
||
object obj3;
|
||
if (paymentInfos == null)
|
||
{
|
||
obj3 = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Data data3 = paymentInfos.data;
|
||
if (data3 == null)
|
||
{
|
||
obj3 = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Attributes attributes3 = data3.attributes;
|
||
obj3 = ((attributes3 == null) ? null : attributes3.paymentInfos[0]?.billingAddress?.addressOfficialLineFirst);
|
||
}
|
||
}
|
||
string value3 = (string)obj3;
|
||
object obj4;
|
||
if (paymentInfos == null)
|
||
{
|
||
obj4 = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Data data4 = paymentInfos.data;
|
||
if (data4 == null)
|
||
{
|
||
obj4 = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Attributes attributes4 = data4.attributes;
|
||
obj4 = ((attributes4 == null) ? null : attributes4.paymentInfos[0]?.billingAddress?.addressOfficialLineSecond);
|
||
}
|
||
}
|
||
string value4 = (string)obj4;
|
||
object obj5;
|
||
if (paymentInfos == null)
|
||
{
|
||
obj5 = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Data data5 = paymentInfos.data;
|
||
if (data5 == null)
|
||
{
|
||
obj5 = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Attributes attributes5 = data5.attributes;
|
||
obj5 = ((attributes5 == null) ? null : attributes5.paymentInfos[0]?.billingAddress?.addressOfficialCity);
|
||
}
|
||
}
|
||
string value5 = (string)obj5;
|
||
object obj6;
|
||
if (paymentInfos == null)
|
||
{
|
||
obj6 = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Data data6 = paymentInfos.data;
|
||
if (data6 == null)
|
||
{
|
||
obj6 = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Attributes attributes6 = data6.attributes;
|
||
obj6 = ((attributes6 == null) ? null : attributes6.paymentInfos[0]?.billingAddress?.addressOfficialPostalCode);
|
||
}
|
||
}
|
||
string value6 = (string)obj6;
|
||
object obj7;
|
||
if (paymentInfos == null)
|
||
{
|
||
obj7 = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Data data7 = paymentInfos.data;
|
||
if (data7 == null)
|
||
{
|
||
obj7 = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Attributes attributes7 = data7.attributes;
|
||
obj7 = ((attributes7 == null) ? null : attributes7.paymentInfos[0]?.billingAddress?.addressOfficialStateProvince);
|
||
}
|
||
}
|
||
string value7 = (string)obj7;
|
||
object obj8;
|
||
if (paymentInfos == null)
|
||
{
|
||
obj8 = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Data data8 = paymentInfos.data;
|
||
if (data8 == null)
|
||
{
|
||
obj8 = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Attributes attributes8 = data8.attributes;
|
||
obj8 = ((attributes8 == null) ? null : attributes8.paymentInfos[0]?.billingAddress?.addressOfficialCountryCode);
|
||
}
|
||
}
|
||
string text = (string)obj8;
|
||
object obj9;
|
||
if (paymentInfos == null)
|
||
{
|
||
obj9 = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Data data9 = paymentInfos.data;
|
||
if (data9 == null)
|
||
{
|
||
obj9 = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Attributes attributes9 = data9.attributes;
|
||
obj9 = ((attributes9 == null) ? null : attributes9.paymentInfos[0]?.phone.phoneOfficeNumber);
|
||
}
|
||
}
|
||
string value8 = (string)obj9;
|
||
object obj10;
|
||
if (paymentInfos == null)
|
||
{
|
||
obj10 = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Data data10 = paymentInfos.data;
|
||
if (data10 == null)
|
||
{
|
||
obj10 = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Attributes attributes10 = data10.attributes;
|
||
obj10 = ((attributes10 == null) ? null : attributes10.paymentInfos[0]?.phone.phoneOfficeAreaCode);
|
||
}
|
||
}
|
||
string text2 = (string)obj10;
|
||
string cardName = cardType.cardName;
|
||
if (string.IsNullOrEmpty(value8) || text2 == null)
|
||
{
|
||
object obj11;
|
||
if (paymentInfos == null)
|
||
{
|
||
obj11 = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Data data11 = paymentInfos.data;
|
||
if (data11 == null)
|
||
{
|
||
obj11 = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Attributes attributes11 = data11.attributes;
|
||
obj11 = ((attributes11 == null) ? null : attributes11.paymentInfos[0]?.billingAddress?.addressOfficialCountryCode);
|
||
}
|
||
}
|
||
string dataCountry = (string)obj11;
|
||
if (!string.IsNullOrEmpty(dataCountry))
|
||
{
|
||
NationalList nationalList = (from c in new NationalData().getMation()
|
||
where c.payment.billingAddress.countryCode.ToUpper() == dataCountry.ToUpper()
|
||
select c).FirstOrDefault();
|
||
if (nationalList != null)
|
||
{
|
||
if (nationalList.payment.phoneNumber.number.StartsWith("410"))
|
||
{
|
||
value8 = nationalList.payment.phoneNumber.number.Replace("410", "");
|
||
text2 = "410";
|
||
}
|
||
else
|
||
{
|
||
value8 = nationalList.payment.phoneNumber.number;
|
||
text2 = nationalList.payment.phoneNumber.areaCode;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
string text3 = "addressOfficialLineFirst=" + Tools.ToUrlEncode(value3) + "&addressOfficialLineSecond=" + Tools.ToUrlEncode(value4) + "&addressOfficialCity=" + Tools.ToUrlEncode(value5) + "&addressOfficialStateProvince=" + Tools.ToUrlEncode(value7) + "&addressOfficialPostalCode=" + Tools.ToUrlEncode(value6) + "&addressOfficialCountryCode=" + Tools.ToUrlEncode(text) + "&phoneOfficeAreaCode=" + Tools.ToUrlEncode(text2) + "&phoneOfficeNumber=" + Tools.ToUrlEncode(value8) + "&billingFirstName=" + Tools.ToUrlEncode(value) + "&billingLastName=" + Tools.ToUrlEncode(value2) + "&iso3CountryCode=" + Tools.ToUrlEncode(text) + "&needsTopUp=false&creditCardType=" + Tools.ToUrlEncode(cardName) + "&paymentMethodType=CreditCard&isCameraInput=false&creditCardNumber=" + Tools.ToUrlEncode(creditCardNumber) + "&creditCardExpirationMonth=" + Tools.ToUrlEncode(creditCardExpirationMonth) + "&creditCardExpirationYear=" + Tools.ToUrlEncode(creditCardExpirationYear) + "&creditVerificationNumber=" + Tools.ToUrlEncode(creditVerificationNumber) + "&guid=" + itunesLogin.Guid;
|
||
if (!string.IsNullOrEmpty(text) && text == "JPN")
|
||
{
|
||
text3 = text3 + "&phoneticBillingLastName=" + Tools.ToUrlEncode(value2) + "&phoneticBillingFirstName=" + Tools.ToUrlEncode(value);
|
||
}
|
||
action?.Invoke(itunesLogin.account, DisplyType.xinxi, "正在添加卡");
|
||
HttpResult httpResult = postUrlencodedItunesWebContext(url, text3, referer, itunesLogin, dictionary);
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
iTunesAccountLoginCache.removeReddemUserInfo(itunesLogin.account, itunesLogin.StdndbyKeyGuid);
|
||
Dictionary<string, object> dictionary2 = (dynamic)Tools.Todejosn<object>(httpResult.Html);
|
||
if ((int)(dynamic)dictionary2["status"] == 0)
|
||
{
|
||
action?.Invoke(itunesLogin.account, DisplyType.forbidden, "成功");
|
||
action?.Invoke(itunesLogin.account, DisplyType.xinxi, "添加成功");
|
||
return true;
|
||
}
|
||
action?.Invoke(itunesLogin.account, DisplyType.error, "失败");
|
||
string text4 = "";
|
||
if (dictionary2.ContainsKey("userPresentableErrorMessage"))
|
||
{
|
||
text4 = (dynamic)dictionary2["userPresentableErrorMessage"];
|
||
}
|
||
if (string.IsNullOrEmpty(text4))
|
||
{
|
||
text4 = new Regex("\"error\":\"([\\s\\S]*?)\"").Match(httpResult.Html).Groups[1].Value;
|
||
}
|
||
text4 = AppleUtlis.Html2Text(text4, isEmorp: false);
|
||
action?.Invoke(itunesLogin.account, DisplyType.xinxi, text4);
|
||
}
|
||
else
|
||
{
|
||
action?.Invoke(itunesLogin.account, DisplyType.xinxi, "添加失败,请重试");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
action?.Invoke(itunesLogin.account, DisplyType.xinxi, "查询错误#2");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
action?.Invoke(itunesLogin.account, DisplyType.xinxi, "查询错误");
|
||
}
|
||
return false;
|
||
}
|
||
|
||
private AddPaymentCardType GetCardType(AppleItunesLogin itunesLogin, string ccNumber)
|
||
{
|
||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||
dictionary.Add("X-Apple-Store-Front", itunesLogin.software);
|
||
string url = "https://p" + itunesLogin.ServerId + "-buy.itunes.apple.com/account/card/type";
|
||
string referer = "https://finance-app.itunes.apple.com/account/manage-payments/add-payment";
|
||
HttpResult httpResult = postUrlencodedItunesWebContext(url, "ccNumber=" + ccNumber, referer, itunesLogin, dictionary);
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
return Tools.Todejosn<AddPaymentCardType>(httpResult.Html);
|
||
}
|
||
return null;
|
||
}
|
||
|
||
public bool PaymentChallengeInitiate(string paymentId, string cvv, string creditCardExpirationMonth, string creditCardExpirationYear, AppleItunesLogin itunesLogin, ref string msg)
|
||
{
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, "正在激活支付方式...");
|
||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||
dictionary.Add("X-Apple-Store-Front", "143465-19,12");
|
||
string postData = "{\"guid\":\"" + itunesLogin.Guid + "\",\"cvv\":\"" + cvv + "\",\"creditCardExpirationMonth\":\"" + HttpUtility.HtmlEncode(creditCardExpirationMonth) + "\",\"creditCardExpirationYear\":\"" + HttpUtility.HtmlEncode(creditCardExpirationYear) + "\"}";
|
||
string url = "https://p" + itunesLogin.ServerId + "-buy.itunes.apple.com/account/challenge/initiate/" + paymentId;
|
||
string referer = "https://finance-app.itunes.apple.com";
|
||
HttpResult httpResult = postJsonItunesWebContext(url, postData, referer, itunesLogin, dictionary, addToken: true);
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
Dictionary<string, object> dictionary2 = (dynamic)Tools.Todejosn<object>(httpResult.Html);
|
||
string text = dictionary2["status"].ToString();
|
||
if (text != null && text == "-1")
|
||
{
|
||
if (httpResult.Html.Contains("userPresentableErrorMessage"))
|
||
{
|
||
msg = "失败:" + (dynamic)dictionary2["userPresentableErrorMessage"];
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, msg);
|
||
return false;
|
||
}
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, msg);
|
||
return false;
|
||
}
|
||
if (text != null && text == "0")
|
||
{
|
||
msg = "支付方式激活成功";
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, msg);
|
||
return true;
|
||
}
|
||
}
|
||
action?.Invoke(base.notyKey, DisplyType.xinxi, msg);
|
||
return false;
|
||
}
|
||
|
||
public PaymentList getPaymentInfos(AppleItunesLogin itunesLogin)
|
||
{
|
||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||
dictionary.Add("X-Apple-Store-Front", "143465-19,12");
|
||
string url = "https://p" + itunesLogin.ServerId + "-buy.itunes.apple.com/account/stackable/paymentInfos?managePayments=true&guid=" + itunesLogin.Guid + "&xToken=" + HttpUtility.UrlEncode(itunesLogin.xtoken);
|
||
HttpResult jsonItunesWebContext = getJsonItunesWebContext(url, "https://finance-app.itunes.apple.com/account/manage-payments", itunesLogin, dictionary, addToken: true);
|
||
if (jsonItunesWebContext.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
return Tools.Todejosn<PaymentList>(jsonItunesWebContext.Html);
|
||
}
|
||
return null;
|
||
}
|
||
|
||
private string getPaymentList(AppleItunesLogin itunesLogin)
|
||
{
|
||
PaymentList paymentInfos = getPaymentInfos(itunesLogin);
|
||
if (paymentInfos != null && paymentInfos != null)
|
||
{
|
||
int? num = paymentInfos.data?.attributes?.paymentInfos.Count();
|
||
if (num > 0 && paymentInfos != null)
|
||
{
|
||
PaymentList.Data data = paymentInfos.data;
|
||
int? obj;
|
||
if (data == null)
|
||
{
|
||
obj = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Attributes attributes = data.attributes;
|
||
obj = ((attributes != null) ? new int?(attributes.paymentInfos[0].validationErrors.Count()) : null);
|
||
}
|
||
num = obj;
|
||
if (num > 0)
|
||
{
|
||
string text = "";
|
||
object obj2;
|
||
if (paymentInfos == null)
|
||
{
|
||
obj2 = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Data data2 = paymentInfos.data;
|
||
if (data2 == null)
|
||
{
|
||
obj2 = null;
|
||
}
|
||
else
|
||
{
|
||
PaymentList.Attributes attributes2 = data2.attributes;
|
||
obj2 = ((attributes2 != null) ? attributes2.paymentInfos[0].validationErrors : null);
|
||
}
|
||
}
|
||
PaymentList.ValidationErrors[] array = (PaymentList.ValidationErrors[])obj2;
|
||
foreach (PaymentList.ValidationErrors validationErrors in array)
|
||
{
|
||
if (!text.Contains(validationErrors.errorShortMessage))
|
||
{
|
||
text += validationErrors.errorShortMessage;
|
||
}
|
||
}
|
||
return text;
|
||
}
|
||
}
|
||
}
|
||
return "";
|
||
}
|
||
|
||
public bool getAccountSummary(AppleItunesLogin itunelogin, bool openOwe, string notityKey, ref bool openOweReust)
|
||
{
|
||
string url = "https://p" + itunelogin.ServerId + "-buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/accountSummary";
|
||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||
dictionary.Add("X-Apple-Store-Front", "143465-19,12");
|
||
string userAgent = itunelogin.Headers["User-Agent"].ToString();
|
||
itunelogin.Headers["User-Agent"] = "iTunes/12.12.2 (Windows; Microsoft Windows 10 x64 Professional Edition (Build 19043); x64) AppleWebKit/7612.2009.1030.30 (dt:2)";
|
||
HttpResult itunesWebContext = getItunesWebContext(url, "https://music.apple.com/WebObjects/MZStore.woa/wa/viewGrouping?cc=us&id=1", itunelogin, dictionary, addToken: true);
|
||
itunelogin.Headers["User-Agent"] = userAgent;
|
||
if (itunesWebContext.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
if (itunesWebContext.Html.Contains("家人共享"))
|
||
{
|
||
action?.Invoke(notityKey, DisplyType.xiaofeijine, "家人共享");
|
||
}
|
||
else
|
||
{
|
||
action?.Invoke(notityKey, DisplyType.xiaofeijine, "无");
|
||
}
|
||
string value = new Regex("付款信息:([\\s\\S]*?)<div class=\"action\">").Match(itunesWebContext.Html).Groups[1].Value;
|
||
string text = AppleUtlis.Html2Text(new Regex("info\">([\\s\\S]*?)</div>").Match(value).Groups[1].Value).Replace("••••••••••••", "•••");
|
||
if (!text.Contains("没有信用卡记录"))
|
||
{
|
||
string paymentList = getPaymentList(itunelogin);
|
||
text += paymentList;
|
||
}
|
||
string[] array = Regex.Split(new Regex("class=\"address\">([\\s\\S]*?)</p>").Match(itunesWebContext.Html).Groups[1].Value, "<br/>", RegexOptions.IgnoreCase);
|
||
string text2 = "";
|
||
string[] array2 = array;
|
||
foreach (string text3 in array2)
|
||
{
|
||
text2 = text2 + ((text2 == "") ? "" : " , ") + text3.Replace("\n", "").Trim();
|
||
}
|
||
string value2 = new Regex("国家或地区([\\s\\S]*?)<div class=\"action\">").Match(itunesWebContext.Html).Groups[1].Value;
|
||
string arg = AppleUtlis.Html2Text(new Regex("info\">([\\s\\S]*?)</div>").Match(value2).Groups[1].Value);
|
||
string value3 = new Regex("上次购买的项目([\\s\\S]*?)<div class=\"action\">").Match(itunesWebContext.Html).Groups[1].Value;
|
||
string arg2 = AppleUtlis.Html2Text(new Regex("info\">([\\s\\S]*?)</div>").Match(value3).Groups[1].Value);
|
||
string value4 = new Regex("Apple ID 余额([\\s\\S]*?)<div class=\"action\">").Match(itunesWebContext.Html).Groups[1].Value;
|
||
if (string.IsNullOrEmpty(value4))
|
||
{
|
||
value4 = new Regex("apple-id-account([\\s\\S]*?)<div class=\"action\">").Match(itunesWebContext.Html).Groups[1].Value;
|
||
}
|
||
string value5 = new Regex("订阅:([\\s\\S]*?)<div class=\"action\">").Match(itunesWebContext.Html).Groups[1].Value;
|
||
string text4 = AppleUtlis.Html2Text(new Regex("info\">([\\s\\S]*?)</div>").Match(value5).Groups[1].Value);
|
||
string arg3 = AppleUtlis.Html2Text(new Regex("info\">([\\s\\S]*?)</div>").Match(value4).Groups[1].Value, isEmorp: false);
|
||
action?.Invoke(notityKey, DisplyType.qt1, text);
|
||
action?.Invoke(notityKey, DisplyType.qt2, text2);
|
||
action?.Invoke(notityKey, DisplyType.qt3, arg3);
|
||
action?.Invoke(notityKey, DisplyType.shengri, arg2);
|
||
action?.Invoke(notityKey, DisplyType.guojia, arg);
|
||
openOweReust = false;
|
||
if (openOwe)
|
||
{
|
||
action?.Invoke(notityKey, DisplyType.xinxi, "正在查询欠费状态");
|
||
string url2 = "https://p" + itunelogin.ServerId + "-buy.itunes.apple.com/commerce/account/purchases?isJsonApiFormat=true&page=1";
|
||
HttpResult itunesWebContext2 = getItunesWebContext(url2, "https://music.apple.com/WebObjects/MZStore.woa/wa/viewGrouping?cc=us&id=1", itunelogin, dictionary, addToken: true);
|
||
if (itunesWebContext2.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
string config = AppSysConfig.getConfig("EnableCheckArrearage");
|
||
openOweReust = true;
|
||
int num = 1;
|
||
array2 = AppSysConfig.getConfig("openOweKeywords").Split('|');
|
||
foreach (string value6 in array2)
|
||
{
|
||
if (itunesWebContext2.Html.Contains(value6) || (itunesWebContext2.Html.Contains("无法授权") && config == "1"))
|
||
{
|
||
num = ((!(config == "1")) ? 2 : CheckArrearage(itunelogin));
|
||
break;
|
||
}
|
||
}
|
||
switch (num)
|
||
{
|
||
case 2:
|
||
openOweReust = true;
|
||
action?.Invoke(notityKey, DisplyType.gameCount, "欠费");
|
||
break;
|
||
case 1:
|
||
action?.Invoke(notityKey, DisplyType.gameCount, "正常");
|
||
break;
|
||
default:
|
||
openOweReust = false;
|
||
action?.Invoke(notityKey, DisplyType.gameCount, "未知");
|
||
break;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
action?.Invoke(notityKey, DisplyType.gameCount, "未知");
|
||
}
|
||
}
|
||
action?.Invoke(notityKey, DisplyType.xinxi, "查询完成,订阅 :" + text4);
|
||
return true;
|
||
}
|
||
action?.Invoke(notityKey, DisplyType.xinxi, "网络请求失败,请重新查询");
|
||
return false;
|
||
}
|
||
|
||
public int CheckArrearage(AppleItunesLogin itunelogin)
|
||
{
|
||
string value = "X-Dsid=" + itunelogin.dsis + ";";
|
||
foreach (KeyValuePair<string, string> cooki in itunelogin.cookis)
|
||
{
|
||
if (cooki.Key == "wosid-lite")
|
||
{
|
||
value = cooki.Key + "=" + cooki.Value;
|
||
}
|
||
}
|
||
HttpResult httpResult = APIUtlis.serviceSend(Tools.Toenjson(new Dictionary<string, object>
|
||
{
|
||
{ "xCookie", value },
|
||
{ "dsid", itunelogin.dsis },
|
||
{ "serverId", itunelogin.ServerId },
|
||
{ "token", itunelogin.xtoken },
|
||
{ "storFront", itunelogin.software },
|
||
{ "xGuid", itunelogin.Guid },
|
||
{ "type", "ICheckArrearage" }
|
||
}));
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
dynamic val = Tools.Todejosn<object>(httpResult.Html);
|
||
if (val["Code"] == "0000")
|
||
{
|
||
string text = val["Data"];
|
||
if (!string.IsNullOrEmpty(text))
|
||
{
|
||
dynamic val2 = Tools.Todejosn<object>(text);
|
||
if (text.Contains("code") && val2["code"] == "0000")
|
||
{
|
||
string text2 = val2["data"];
|
||
if (text2 == "arrearage")
|
||
{
|
||
return 2;
|
||
}
|
||
if (text2 == "normal")
|
||
{
|
||
return 1;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return 3;
|
||
}
|
||
|
||
public DisplyState getItunesDisplyState(AppleItunesLogin itunelogin)
|
||
{
|
||
string url = "https://p" + itunelogin.ServerId + "-buy.itunes.apple.com/WebObjects/MZBuy.woa/wa/buyProduct";
|
||
string postData = $"=&addFunds=true&amount=1000&creditDisplay={itunelogin.Balance}&goBackToAccountSettings=true&guid={itunelogin.Guid}&kbsync=&machineName=DESKTOP-NRJTM70&needDiv=1";
|
||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||
dictionary.Add("X-Apple-Store-Front", itunelogin.software);
|
||
HttpResult httpResult = postItunesWebContext(url, postData, "", itunelogin, dictionary);
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
if (GetKeyValue("<key>dialogId</key>", "<string>", "</string>", httpResult.Html) == "MZCommerce.AccountDisabled")
|
||
{
|
||
return DisplyState.Disply;
|
||
}
|
||
return DisplyState.None;
|
||
}
|
||
return DisplyState.Unknown;
|
||
}
|
||
|
||
private string GetPostDataCountryChangen(PaymentInfo payment)
|
||
{
|
||
string text = "iso3CountryCode=" + payment.billingAddress.countryCode + "&addressOfficialCountryCode=" + payment.billingAddress.countryCode + "&agreedToTerms=1&paymentMethodVersion=2.0&needsTopUp=false&paymentMethodType=None";
|
||
text = text + "&billingFirstName=" + HttpUtility.UrlEncode(payment.ownerName.firstName);
|
||
text = text + "&billingLastName=" + HttpUtility.UrlEncode(payment.ownerName.lastName);
|
||
text = text + "&addressOfficialLineFirst=" + HttpUtility.UrlEncode(payment.billingAddress.line1);
|
||
text = text + "&addressOfficialLineSecond=" + HttpUtility.UrlEncode(payment.billingAddress.line2);
|
||
text = text + "&addressOfficialCity=" + HttpUtility.UrlEncode(payment.billingAddress.city);
|
||
text = text + "&addressOfficialPostalCode=" + HttpUtility.UrlEncode(payment.billingAddress.postalCode);
|
||
if (payment.phoneNumber.number.StartsWith("410"))
|
||
{
|
||
text = text + "&phoneOfficeNumber=" + payment.phoneNumber.number.Replace("410", "");
|
||
text += "&phoneOfficeAreaCode=410";
|
||
}
|
||
else
|
||
{
|
||
text = text + "&phoneOfficeNumber=" + payment.phoneNumber.number;
|
||
}
|
||
if (!string.IsNullOrEmpty(payment.phoneNumber.areaCode))
|
||
{
|
||
text = text + "&phoneOfficeAreaCode=" + payment.phoneNumber.areaCode;
|
||
}
|
||
if (!string.IsNullOrEmpty(payment.billingAddress.stateProvinceName))
|
||
{
|
||
text = text + "&addressOfficialStateProvince=" + HttpUtility.UrlEncode(payment.billingAddress.stateProvinceName);
|
||
}
|
||
if (!string.IsNullOrEmpty(payment.billingAddress.suburb))
|
||
{
|
||
text = text + "&addressOfficialSuburb=" + HttpUtility.UrlEncode(payment.billingAddress.suburb);
|
||
}
|
||
if (payment.billingAddress.countryCode == "JPN")
|
||
{
|
||
text += "&phoneticBillingLastName=xingpingying&phoneticBillingFirstName=mingpingyin";
|
||
}
|
||
if (!string.IsNullOrEmpty(payment.itAppend))
|
||
{
|
||
text = text + "&" + payment.itAppend;
|
||
}
|
||
return text;
|
||
}
|
||
|
||
public bool itunesCountryChangen(AppleItunesLogin login, PaymentInfo payment, bool _openVpn, ref string msg)
|
||
{
|
||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||
dictionary.Add("X-Apple-Store-Front", login.software);
|
||
openVpn = _openVpn;
|
||
base.appleId = login.account;
|
||
string postDataCountryChangen = GetPostDataCountryChangen(payment);
|
||
HttpResult httpResult = postUrlencodedItunesWebContext("https://p" + login.ServerId + "-buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/editBillingInfoSrv", postDataCountryChangen, "https://finance-app.itunes.apple.com/account/storefront/edit/billing-info", login, dictionary);
|
||
msg = "请求未知异常";
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
iTunesAccountLoginCache.removeReddemUserInfo(login.account, login.StdndbyKeyGuid);
|
||
iCloudAccountLoginCache.removeUserInfoByAppleId(login.account, login.pwd);
|
||
login.Area = AppleUtlis.GetAreaCodeByCode(payment.billingAddress.countryCode);
|
||
login.software = AppleUtlis.GetStoreIdByCode(payment.billingAddress.countryCode);
|
||
Dictionary<string, object> dictionary2 = (dynamic)Tools.Todejosn<object>(httpResult.Html);
|
||
if ((int)(dynamic)dictionary2["status"] == 0)
|
||
{
|
||
msg = "转换完成";
|
||
return true;
|
||
}
|
||
if (httpResult.Html.Contains("MZCommerce.AccountDisabled"))
|
||
{
|
||
msg = "失败:账号已被禁用";
|
||
return false;
|
||
}
|
||
if (httpResult.Html.Contains("localizedMessage"))
|
||
{
|
||
msg = "失败:" + ((dynamic)dictionary2["result"])["validationResults"][0]["localizedMessage"];
|
||
return false;
|
||
}
|
||
try
|
||
{
|
||
if (httpResult.Html.Contains("errorString") && httpResult.Html.Contains("validationResults"))
|
||
{
|
||
msg = "失败:" + ((dynamic)dictionary2["result"])["validationResults"][0]["errorString"];
|
||
return false;
|
||
}
|
||
if (httpResult.Html.Contains("userPresentableErrorMessage"))
|
||
{
|
||
msg = "失败:" + (dynamic)dictionary2["userPresentableErrorMessage"];
|
||
return false;
|
||
}
|
||
if (httpResult.Html.Contains("errorString"))
|
||
{
|
||
msg = "失败:" + ((dynamic)dictionary2["result"])[0]["errorString"];
|
||
return false;
|
||
}
|
||
msg = "消息无法处理,返回内容:" + httpResult.Html;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
APIUtlis.ApiSeriveError(ex);
|
||
msg = "出错误了:" + httpResult.Html;
|
||
}
|
||
return false;
|
||
}
|
||
msg = "请求错误:状态 (" + (int)httpResult.StatusCode + ")";
|
||
return false;
|
||
}
|
||
|
||
public string getAccountCredit(AppleItunesLogin itunesLogin)
|
||
{
|
||
string url = "https://se.itunes.apple.com/WebObjects/MZStoreElements.woa/wa/personalizedGroupingLinks";
|
||
string postData = "";
|
||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||
dictionary.Add("X-Apple-Store-Front", itunesLogin.software);
|
||
HttpResult httpResult = postUrlencodedItunesWebContext(url, postData, "https://music.apple.com/", itunesLogin, dictionary);
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
Dictionary<string, object> dictionary2 = (dynamic)Tools.Todejosn<object>(httpResult.Html);
|
||
if (dictionary2.ContainsKey("credit"))
|
||
{
|
||
return dictionary2["credit"] as string;
|
||
}
|
||
}
|
||
return "";
|
||
}
|
||
|
||
public bool getAccountStateMsg(AppleAcount account, ref string msg, ref AppleItunesLogin itunesLoginRef)
|
||
{
|
||
base.appleId = account.appleId;
|
||
msg = "网络请求失败,请重试";
|
||
AppleItunesLogin appleItunesLogin = null;
|
||
string msgReust = "";
|
||
appleItunesLogin = ((!AppSysConfig.iTunesisRemoteLogin) ? appleLogin(account.appleId, account.applePwd + (account.isDoubleModl ? account.DoublePwd : ""), 1, ref msgReust, out var _) : remoteAppleLogin(account.appleId, account.applePwd + (account.isDoubleModl ? account.DoublePwd : ""), ref msgReust, 2));
|
||
if (appleItunesLogin != null)
|
||
{
|
||
if (account.isDoubleModl)
|
||
{
|
||
appleItunesLogin.pwd = account.applePwd;
|
||
}
|
||
iTunesAccountLoginCache.addReddemUserInfo(appleItunesLogin.account, appleItunesLogin);
|
||
itunesLoginRef = appleItunesLogin;
|
||
if (!(appleItunesLogin.isDisabledAccount.ToLower() == "true"))
|
||
{
|
||
msg = "账号正常 ,账号余额:" + (string.IsNullOrEmpty(appleItunesLogin.Balance) ? "0" : appleItunesLogin.Balance) + ",国家:" + appleItunesLogin.Area;
|
||
}
|
||
else
|
||
{
|
||
msg = "账号已被禁用 ,账号余额:" + (string.IsNullOrEmpty(appleItunesLogin.Balance) ? "0" : appleItunesLogin.Balance) + ",国家:" + appleItunesLogin.Area;
|
||
}
|
||
return true;
|
||
}
|
||
msg = msgReust;
|
||
return false;
|
||
}
|
||
|
||
public void appGameUrlLog(string account, string reust)
|
||
{
|
||
try
|
||
{
|
||
if (!Directory.Exists(ConfigUtlis.path + "游戏获取失败记录"))
|
||
{
|
||
Directory.CreateDirectory(ConfigUtlis.path + "游戏获取失败记录");
|
||
}
|
||
if (!Directory.Exists(dirName))
|
||
{
|
||
Directory.CreateDirectory(dirName);
|
||
File.AppendAllText(dirName + "\\" + account + ".txt", account.ToString() + "\n\n", Encoding.UTF8);
|
||
}
|
||
File.AppendAllText(dirName + "\\" + account + ".txt", reust.ToString() + "\n\n", Encoding.UTF8);
|
||
}
|
||
catch (Exception)
|
||
{
|
||
}
|
||
}
|
||
|
||
public string[] getGameInfo(string ur, string software)
|
||
{
|
||
string value = new Regex("id([\\d]+)").Match(ur).Groups[1].Value;
|
||
if (ur.Contains("music.apple"))
|
||
{
|
||
value = AppleNetworkBase.GetToken(ur, "?i=", "");
|
||
}
|
||
Dictionary<string, object> postData = new Dictionary<string, object>
|
||
{
|
||
{ "gameid", value },
|
||
{ "software", software },
|
||
{
|
||
"token",
|
||
AppSysConfig.userToken
|
||
}
|
||
};
|
||
HttpResult httpResult = new ApiNetReq().doPost(postData, "ApiGetGameInfo");
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
dynamic val = Tools.Todejosn<object>(httpResult.Html);
|
||
if (val["Code"] == "0000")
|
||
{
|
||
string text = val["Data"]["serverData"];
|
||
if (!string.IsNullOrEmpty(text) && text != "&")
|
||
{
|
||
return new string[2]
|
||
{
|
||
text,
|
||
val["Data"]["pageData"]
|
||
};
|
||
}
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
|
||
public void putGameInfo(string ur, string software, string serverData, string pageData)
|
||
{
|
||
string text = "";
|
||
text = ((!ur.Contains("music.apple")) ? Regex.Match(ur, "/id([\\d+]{6,15})(\\S*?)$", RegexOptions.Multiline).Groups[1].Value : Regex.Match(ur, "i=([\\d+]{6,15})(\\S*?)$", RegexOptions.Multiline).Groups[1].Value);
|
||
Dictionary<string, object> postData = new Dictionary<string, object>
|
||
{
|
||
{ "gameid", text },
|
||
{ "software", software },
|
||
{ "url", ur },
|
||
{ "serverData", serverData },
|
||
{ "pageData", pageData },
|
||
{
|
||
"token",
|
||
AppSysConfig.userToken
|
||
}
|
||
};
|
||
if (!string.IsNullOrEmpty(serverData) && serverData != "&")
|
||
{
|
||
new ApiNetReq().doPost(postData, "ApiPutGameInfo");
|
||
}
|
||
}
|
||
|
||
public Dictionary<string, string> ConveDicTobuyParams(string buyParams)
|
||
{
|
||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||
string[] array = buyParams.Split('&');
|
||
for (int i = 0; i < array.Length; i++)
|
||
{
|
||
string[] array2 = array[i].Split('=');
|
||
if (array2.Length == 2)
|
||
{
|
||
dictionary.TryAddDic(array2[0].Trim(), array2[1].Trim());
|
||
}
|
||
}
|
||
return dictionary;
|
||
}
|
||
|
||
public GameDataInfo ParsingGameData(string GameInfoHtml, string getUrl = "")
|
||
{
|
||
string text = "";
|
||
string token = AppleNetworkBase.GetToken(GameInfoHtml, "serverData=", "</script>");
|
||
if (!string.IsNullOrEmpty(token))
|
||
{
|
||
try
|
||
{
|
||
string text2 = "";
|
||
if (!string.IsNullOrEmpty(getUrl))
|
||
{
|
||
text2 = ((!getUrl.Contains("music.apple")) ? Regex.Match(getUrl, "/id([\\d+]{6,15})(\\S*?)$", RegexOptions.Multiline).Groups[1].Value : Regex.Match(getUrl, "i=([\\d+]{6,15})(\\S*?)$", RegexOptions.Multiline).Groups[1].Value);
|
||
}
|
||
Dictionary<string, object> dictionary = null;
|
||
try
|
||
{
|
||
dictionary = Tools.Todejosn<Dictionary<string, object>>(token);
|
||
}
|
||
catch (Exception)
|
||
{
|
||
return null;
|
||
}
|
||
if (dictionary != null)
|
||
{
|
||
Dictionary<string, object> dictionary2 = null;
|
||
Dictionary<string, object> dictionary3 = null;
|
||
if (dictionary.ContainsKey("storePlatformData") && (dictionary["storePlatformData"] as Dictionary<string, object>).ContainsKey("product-dv-product") && (((dynamic)dictionary["storePlatformData"])["product-dv-product"] as Dictionary<string, object>).ContainsKey("results"))
|
||
{
|
||
dictionary2 = ((dynamic)dictionary["storePlatformData"])["product-dv-product"]["results"];
|
||
}
|
||
if (dictionary.ContainsKey("pageData") && (dictionary["pageData"] as Dictionary<string, object>).ContainsKey("metricsBase"))
|
||
{
|
||
dictionary3 = ((dynamic)dictionary["pageData"])["metricsBase"];
|
||
}
|
||
if (dictionary2 != null && dictionary3 != null)
|
||
{
|
||
foreach (string key in dictionary2.Keys)
|
||
{
|
||
if (string.IsNullOrEmpty(text2))
|
||
{
|
||
text = ((dynamic)dictionary2[key ?? ""])["offers"][0]["buyParams"];
|
||
continue;
|
||
}
|
||
Dictionary<string, object> dictionary4 = (dynamic)dictionary2[key ?? ""];
|
||
if (dictionary4.ContainsKey("children"))
|
||
{
|
||
Dictionary<string, object> dictionary5 = (dynamic)dictionary4["children"];
|
||
foreach (string key2 in dictionary5.Keys)
|
||
{
|
||
if (key2 == text2)
|
||
{
|
||
text = ((dynamic)dictionary5[key2 ?? ""])["offers"][0]["buyParams"];
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
else if (key == text2)
|
||
{
|
||
text = ((dynamic)dictionary2[key ?? ""])["offers"][0]["buyParams"];
|
||
break;
|
||
}
|
||
}
|
||
dynamic val = dictionary3["pageId"];
|
||
dynamic val2 = dictionary3["page"];
|
||
dynamic val3 = dictionary3["pageType"];
|
||
return new GameDataInfo
|
||
{
|
||
buyParams2 = text + "&",
|
||
page = val2,
|
||
pageId = val,
|
||
pageType = val3,
|
||
metricsBase = Tools.Toenjson(dictionary3)
|
||
};
|
||
}
|
||
return null;
|
||
}
|
||
}
|
||
catch (Exception ex2)
|
||
{
|
||
APIUtlis.ApiSeriveError(ex2);
|
||
return null;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
try
|
||
{
|
||
Dictionary<string, object> dictionary6 = null;
|
||
try
|
||
{
|
||
dictionary6 = Tools.Todejosn<Dictionary<string, object>>(GameInfoHtml);
|
||
}
|
||
catch (Exception)
|
||
{
|
||
return null;
|
||
}
|
||
if (dictionary6 != null)
|
||
{
|
||
if (dictionary6.ContainsKey("storePlatformPrewarmDataKey"))
|
||
{
|
||
Dictionary<string, object> dictionary7 = null;
|
||
Dictionary<string, object> dictionary8 = null;
|
||
if (dictionary6.ContainsKey("storePlatformData") && (dictionary6["storePlatformData"] as Dictionary<string, object>).ContainsKey("product-dv-product") && (((dynamic)dictionary6["storePlatformData"])["product-dv-product"] as Dictionary<string, object>).ContainsKey("results"))
|
||
{
|
||
dictionary7 = ((dynamic)dictionary6["storePlatformData"])["product-dv-product"]["results"];
|
||
}
|
||
if (dictionary6.ContainsKey("metricsBase"))
|
||
{
|
||
dictionary8 = (dynamic)dictionary6["metricsBase"];
|
||
}
|
||
if (dictionary7 != null && dictionary8 != null)
|
||
{
|
||
foreach (string key3 in dictionary7.Keys)
|
||
{
|
||
text = ((dynamic)dictionary7[key3 ?? ""])["offers"][0]["buyParams"];
|
||
}
|
||
dynamic val4 = dictionary8["pageId"];
|
||
dynamic val5 = dictionary8["page"];
|
||
dynamic val6 = dictionary8["pageType"];
|
||
return new GameDataInfo
|
||
{
|
||
buyParams2 = text,
|
||
page = val5,
|
||
pageId = val4,
|
||
pageType = val6,
|
||
metricsBase = Tools.Toenjson(dictionary8)
|
||
};
|
||
}
|
||
return null;
|
||
}
|
||
if (dictionary6.ContainsKey("storePlatformData") && (((dynamic)dictionary6["storePlatformData"] != null) ? true : false))
|
||
{
|
||
Dictionary<string, object> dictionary9 = null;
|
||
Dictionary<string, object> dictionary10 = null;
|
||
if (dictionary6.ContainsKey("storePlatformData") && (dictionary6["storePlatformData"] as Dictionary<string, object>).ContainsKey("product-dv") && (((dynamic)dictionary6["storePlatformData"])["product-dv"] as Dictionary<string, object>).ContainsKey("results"))
|
||
{
|
||
dictionary9 = ((dynamic)dictionary6["storePlatformData"])["product-dv"]["results"];
|
||
}
|
||
if (dictionary6.ContainsKey("pageData") && (dictionary6["pageData"] as Dictionary<string, object>).ContainsKey("metricsBase"))
|
||
{
|
||
dictionary10 = ((dynamic)dictionary6["pageData"])["metricsBase"];
|
||
}
|
||
if (dictionary9 != null && dictionary10 != null)
|
||
{
|
||
foreach (string key4 in dictionary9.Keys)
|
||
{
|
||
text = ((dynamic)dictionary9[key4 ?? ""])["offers"][0]["buyParams"];
|
||
}
|
||
dynamic val7 = dictionary10["pageId"];
|
||
dynamic val8 = dictionary10["page"];
|
||
dynamic val9 = dictionary10["pageType"];
|
||
return new GameDataInfo
|
||
{
|
||
buyParams2 = text,
|
||
page = val8,
|
||
pageId = val7,
|
||
pageType = val9,
|
||
metricsBase = Tools.Toenjson(dictionary10)
|
||
};
|
||
}
|
||
return null;
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex4)
|
||
{
|
||
APIUtlis.ApiSeriveError(ex4);
|
||
return null;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
|
||
public string[] getGameDataInfo(string url, AppleItunesLogin itunesLogin, ref string html)
|
||
{
|
||
string[] gameInfo = getGameInfo(url, itunesLogin.software);
|
||
if (gameInfo == null)
|
||
{
|
||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||
dictionary.Add("X-Apple-Store-Front", itunesLogin.software.Split(',')[0] + ",28");
|
||
string userAgent = itunesLogin.Headers["User-Agent"].ToString();
|
||
itunesLogin.Headers["User-Agent"] = "iTunes/12.0.1 (Macintosh; OS X 10.10) AppleWebKit/600.1.3.41";
|
||
HttpResult itunesWebContext = getItunesWebContext(url, "", itunesLogin, dictionary, addToken: false);
|
||
itunesLogin.Headers["User-Agent"] = userAgent;
|
||
if (itunesWebContext.StatusCode == (HttpStatusCode)0)
|
||
{
|
||
int num = 0;
|
||
do
|
||
{
|
||
Thread.Sleep(1000);
|
||
num++;
|
||
itunesWebContext = getItunesWebContext(url, "", itunesLogin, dictionary, addToken: false);
|
||
}
|
||
while (itunesWebContext.StatusCode == (HttpStatusCode)0 && num < 5);
|
||
}
|
||
if (itunesWebContext.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
GameDataInfo gameDataInfo = ParsingGameData(itunesWebContext.Html, url);
|
||
html = itunesWebContext.Html;
|
||
if (gameDataInfo != null)
|
||
{
|
||
putGameInfo(url, itunesLogin.software, gameDataInfo.buyParams2, gameDataInfo.metricsBase);
|
||
return new string[2] { gameDataInfo.buyParams2, gameDataInfo.metricsBase };
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
return gameInfo;
|
||
}
|
||
|
||
public void endGetGame(AppleItunesLogin itunesLogin)
|
||
{
|
||
}
|
||
|
||
public string CreatMdpdipr()
|
||
{
|
||
string text = "ncip,0," + Guid.NewGuid().ToString("n").Substring(0, 8) + ",1,1;st,0,nucaptcha-answer,0;";
|
||
string[] array = "mm,2,19e,184;mm,722a,756,18a;ts,0,722c;mm,192f,4be,1c0;kk,66a,0,nucaptcha-answer;ff,0,nucaptcha-answer;mc,9f,130,5b,nucaptcha-answer;kd,109;fb,957,nucaptcha-answer;mm,41e0,648,1cd;ts,0,dea4;mm,4ac7,1e4,194;ts,0,1296b;kk,33b,1,nucaptcha-answer;ff,0,nucaptcha-answer;mc,7d,f5,5d,nucaptcha-answer;kd,5d4;kd,33e;kd,43;kd,d;kd,86;kd,bc;kd,e;mm,2de,f6,5a,nucaptcha-answer;fb,491,nucaptcha-answer;mm,4a38,2d5,1cb;ts,0,1897c;mm,6de1,1cb,db;ts,0,1f75d;mm,1150,76c,178;kk,1442,6,nucaptcha-answer;ff,1,nucaptcha-answer;fb,28,nucaptcha-answer;mm,1cc,136,61;kk,10c3,6,nucaptcha-answer;ff,1,nucaptcha-answer;mc,4c,143,56,nucaptcha-answer;mc,cf,143,56,nucaptcha-answer;mm,1b0,142,57,nucaptcha-answer;ts,0,23273;kd,46;kd,5d;kd,fd;fb,45a,nucaptcha-answer;kk,6a9,0,nucaptcha-answer;ff,1,nucaptcha-answer;mc,7d,15c,5c,nucaptcha-answer;kd,193;kd,5e;kd,77;kd,102;kd,ff;mm,3e,15c,5d,nucaptcha-answer;fb,114,nucaptcha-answer;mc,8c,262,12a;kk,ef2,5,nucaptcha-answer;ff,0,nucaptcha-answer;mc,66,103,56,nucaptcha-answer;mc,c0,103,56,nucaptcha-answer;mm,1b0,104,57,nucaptcha-answer;kd,89;kd,cc;kd,c;kd,b8;kd,1cc;kd,8f;kd,144;kd,91;kd,2c8;kd,4ea;kd,24f;kd,290;mm,497,107,5a,nucaptcha-answer;ts,0,26f14;mc,667,fb,5e,nucaptcha-answer;mc,108,fb,5e,nucaptcha-answer;kd,a1;fb,252,nucaptcha-answer;mm,15ce,228,1cd;kk,4e7,1,nucaptcha-answer;ff,0,nucaptcha-answer;mc,c0,f3,58,nucaptcha-answer;kd,ee;kd,79;fb,3d3,nucaptcha-answer;mm,5a4e,182,1cd;ts,0,2f473;kk,34e,3,nucaptcha-answer;ff,0,nucaptcha-answer;mc,aa,0,55;kd,38c;kd,177;kd,48;kd,66;kd,1c9;kd,9f;kd,79;kd,6c;kd,14d;kd,e6;kd,169;kd,52;kd,43;kd,fc;mm,17f,e,55,directions-verbose-label;fb,437,nucaptcha-answer;mm,146c7,40a,1cc;ts,0,45313;mm,101d9,751,b0;ts,0,554ec;mm,127e,1f2,14d;kk,2f2,6,nucaptcha-answer;ff,0,nucaptcha-answer;mc,56,12c,58,nucaptcha-answer;mc,d8,12c,58,nucaptcha-answer;kd,202;kd,5de;kd,db;kd,ae9;kd,129;kd,420;kd,232;mm,509,12c,59,nucaptcha-answer;mm,140a,167,a9;ts,0,59fbc;mm,1afe,17c,ba;mm,bd90,17e,ba;ts,0,6784a;fb,7f5,nucaptcha-answer;mm,183ff56,776,dc;ts,0,18a7f95;mm,127a9,5a4,11b;ts,0,18ba73e;kk,485,6,nucaptcha-answer;ff,0,nucaptcha-answer;fb,6d,nucaptcha-answer;kk,779,6,nucaptcha-answer;ff,0,nucaptcha-answer;kd,10c8;fb,71,nucaptcha-answer;mm,16d8b,18f,12c;ts,0,18d326d;kk,ee,6,nucaptcha-answer;ff,0,nucaptcha-answer;fb,c,nucaptcha-answer;mc,6c,f9,fb;mc,6e1,c6,2b,nucaptcha-media;kk,143,6,nucaptcha-answer;ff,0,nucaptcha-answer;mc,6c,110,5e,nucaptcha-answer;fb,1e4,nucaptcha-answer;mc,75,c0,1f,nucaptcha-media;mc,559,113,a9;mm,120,113,a8;mc,2a9,10f,98;mc,64e,10f,98;mc,10ef,10f,98;mc,2748,10f,98;ts,0,18d8663;mc,e98,10f,98;mm,1931,10e,98;mc,ee7,10e,9a;mc,770,10e,9a;ts,0,18dc483;mc,29c0,10e,9a;mc,2119,10e,9a;ts,0,18e0f5c;mm,c16,10e,9b;mc,1029,22c,13c;mm,298,21b,130;mc,83a8,137,6e;ts,0,18eb1db;mc,a38,137,6e;mm,438,13e,6d;mm,ac6d,5cc,1cd;ts,0,18f6cb8;mm,33702,597,1cd;ts,0,192a3ba;mm,13ae2,2cd,1cb;ts,0,193de9c;mm,b43d,4c3,10c;ts,0,19492d9;mm,33f2,60d,fe;mm,aaaf,2ff,18f;ts,0,195717a;mm,53f9,2f4,1cd;ts,0,195c573;mm,10c08,5f1,1bd;ts,0,196d17b;mm,d7bc,725,e4;ts,0,197a937;mm,12c3,59e,1c5;mm,2a79,26e,1c6;ts,0,197e673;kk,24c,6,nucaptcha-answer;ff,0,nucaptcha-answer;mc,43,136,4e,nucaptcha-answer;mc,b0,136,4e,nucaptcha-answer;kd,265;kd,bb;kd,218;kd,3d4;kd,3dd;kd,b6a;kd,222;kd,6cd;kd,514;kd,ae;kd,1b;kd,48e;kd,14e;kd,333;kd,5b;kd,f4;kd,2e1;kd,c7;kd,5e1;ts,0,19824b8;kd,171;kd,34c;kd,268;kd,1ad;kd,46d;kd,444;kd,941;kd,4b6;mm,81f,13c,50,nucaptcha-answer;fb,f2,nucaptcha-answer;mc,80,152,c2;kk,2b4,9,nucaptcha-answer;ff,0,nucaptcha-answer;mc,265,f5,56,nucaptcha-answer;kd,a9;kd,1c7;kd,177;kd,334;kd,1fa;kd,20c;kd,2ec;ts,0,19860e9;kd,134;kd,390;kd,3d2;kd,413;kd,419;kd,3c1;kd,a2;kd,14d;kd,3ed;kd,277;kd,26a;kd,208;kd,19d;kd,15c;kd,151;kd,134;kd,232;kd,ff;mm,1ab,f7,56,nucaptcha-answer;mc,a0f,101,59,nucaptcha-answer;kd,272;kd,425;ts,0,1989d31;mm,440,107,65;kd,112;kd,41c;fb,414,nucaptcha-answer;mc,8b,278,dc;mc,42d,42a,cb;mm,22e,413,b4;kk,5f2,9,nucaptcha-answer;ff,0,nucaptcha-answer;mc,23e,f6,56,nucaptcha-answer;kd,1bf;kd,281;kd,191;kd,10f;kd,1ee;kd,241;kd,42d;mm,ec,fb,58,nucaptcha-answer;kd,36b;kd,278;kd,33d;kd,2c5;kd,71f;ts,0,198dcf5;kd,1b9;kd,1ae;kd,283;kd,223;kd,251;mm,10,106,5c,nucaptcha-answer;fb,562,nucaptcha-answer;mc,6d,3a7,136;kk,3eb,0,nucaptcha-answer;ff,0,nucaptcha-answer;mc,64,12f,5c,nucaptcha-answer;kd,cc;fb,257,nucaptcha-answer;mc,90,1e8,12e;kk,2a7,1,nucaptcha-answer;ff,1,nucaptcha-answer;mm,75,152,5a,nucaptcha-answer;mc,e0,a4,54,nucaptcha-player;kd,146;fb,21d,nucaptcha-answer;mc,7d,2ac,4d,nucaptcha-player;kk,24b,1,nucaptcha-answer;ff,0,nucaptcha-answer;mc,9d,151,56,nucaptcha-answer;kd,ef;kd,307;kd,6b3;mm,d3,147,58,nucaptcha-answer;kd,2bb;fb,252,nucaptcha-answer;mc,67,196,c2;mc,220,131,48,nucaptcha-player;kk,122,5,nucaptcha-answer;ff,0,nucaptcha-answer;mc,11f,f3,57,nucaptcha-answer;kd,2b2;ts,0,19917fc;kd,77;kd,1bb;kd,222;mm,2b2,100,65;fb,99,nucaptcha-answer;mc,86,f9,66;kk,109,1,nucaptcha-answer;ff,0,nucaptcha-answer;mc,87,fe,50,nucaptcha-answer;kd,a3;mc,2ad,106,52,nucaptcha-answer;kd,1ac;mc,1f5,106,52,nucaptcha-answer;kd,127;mc,1d0,106,52,nucaptcha-answer;kd,ac;mc,1fc,106,52,nucaptcha-answer;kd,cb;mc,1c5,10a,52,nucaptcha-answer;kd,53;mc,207,11d,50,nucaptcha-answer;kd,47;kd,4b3;kd,34f;mm,39d,11f,50,nucaptcha-answer;kd,48c;kd,ab6;mm,756,225,1c5;ts,0,19955a9;kd,86c;kd,87a;kd,84e;kd,1276;kd,721;kd,6b4;kd,c6b;ts,0,1999b93;kd,815;kd,ea5;kd,895;kd,9c9;kd,94f;kd,422;kd,3d2;kd,368;ts,0,199d956;kd,639;kd,598;kd,9ca;kd,561;kd,23b;kd,609;kd,605;kd,949;kd,94a;ts,0,19a152e;kd,745;kd,c8;kd,135;kd,499;kd,2b9;kd,290;kd,648;kd,548;kd,231;kd,e;kd,3f0;mm,62b,146,51,nucaptcha-answer;fb,291,nucaptcha-answer;".Split(';');
|
||
int num = new Random().Next(5, 20);
|
||
for (int i = 0; i < num; i++)
|
||
{
|
||
int num2 = new Random(Guid.NewGuid().GetHashCode()).Next(1, array.Length - 1);
|
||
string text2 = array[num2];
|
||
if (!text.Contains(text2))
|
||
{
|
||
text = text + text2 + ";";
|
||
}
|
||
}
|
||
return text.TrimEnd(';');
|
||
}
|
||
|
||
public string GameVerificationOld(string appleId, string pic_str, string wkInt, string salableAdamId, string count, int serverIndex, ref string yzmUrl, ref string getWkUrl, bool isAgent = false)
|
||
{
|
||
HttpResult httpResult = APIUtlis.serviceSend(Tools.Toenjson(new Dictionary<string, object>
|
||
{
|
||
{ "appleId", appleId },
|
||
{ "pic_str", pic_str },
|
||
{ "wkInt", wkInt },
|
||
{ "salableAdamId", salableAdamId },
|
||
{ "count", count },
|
||
{ "serviceIndex", serverIndex },
|
||
{ "type", "IGameVerification" }
|
||
}));
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
dynamic val = Tools.Todejosn<object>(httpResult.Html);
|
||
if (val["Code"] == "0000")
|
||
{
|
||
dynamic val2 = val["Data"];
|
||
dynamic val3 = Tools.Todejosn<object>(val2);
|
||
if (httpResult.Html.Contains("captchaModel"))
|
||
{
|
||
dynamic val4 = val3["captchaModel"];
|
||
if (val4 != null)
|
||
{
|
||
yzmUrl = val4["yzmUrl"];
|
||
getWkUrl = val4["getWkUrl"];
|
||
}
|
||
}
|
||
return val3["msg"];
|
||
}
|
||
_ = ((val["Code"] == "2001" && !isAgent) ? true : false);
|
||
}
|
||
return "";
|
||
}
|
||
|
||
public string CancelSubscription(string subscriptionId, AppleItunesLogin itunesLogin, bool isAgent = false)
|
||
{
|
||
string text = "失败:网络请求失败,无法请求完成";
|
||
string ReueId = "";
|
||
string guidNow = "";
|
||
string text2 = "000000000";
|
||
int serverIndex = itunesLogin.serverIndex;
|
||
string kbsync = getKbsync(itunesLogin.dsis, ref serverIndex, ref ReueId, ref guidNow);
|
||
string postData = "cancelSubscription=true&creditDisplay=" + itunesLogin.Balance + "&guid=" + itunesLogin.Guid + "&hasConfirmedBuySubscription=true&kbsync=" + kbsync + "&machineName=" + itunesLogin.Guid + "&needDiv=1&salableAdamId=" + text2 + "&showIAPExtraDialog=false&showIAPSuccessDialog=false&subscriptionId=" + subscriptionId + "&supportsGpuContentProtection=true";
|
||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||
dictionary.Add("X-Apple-Store-Front", itunesLogin.software);
|
||
string referer = "https://finance-app.itunes.apple.com/";
|
||
string url = "https://p" + itunesLogin.ServerId + "-buy.itunes.apple.com/WebObjects/MZBuy.woa/wa/buyProduct";
|
||
HttpResult httpResult = postItunesWebContext(url, postData, referer, itunesLogin, dictionary);
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
if (httpResult.Html.Contains("purchaseSuccess"))
|
||
{
|
||
return "0000";
|
||
}
|
||
string keyValue = GetKeyValue("<key>customerMessage</key>", "<string>", "</string>", httpResult.Html);
|
||
if (!string.IsNullOrEmpty(keyValue))
|
||
{
|
||
return "失败:" + keyValue;
|
||
}
|
||
string keyValue2 = GetKeyValue("<key>message</key>", "<string>", "</string>", httpResult.Html);
|
||
if (!string.IsNullOrEmpty(keyValue2))
|
||
{
|
||
return "失败:" + keyValue2;
|
||
}
|
||
return "失败:未知异常";
|
||
}
|
||
return "失败:网络请求失败,无法请求完成";
|
||
}
|
||
|
||
public string CancelSubscription(string appleId, string applePwd, string subscriptionId, string guid, int serverIndex, bool isAgent = false)
|
||
{
|
||
HttpResult httpResult = APIUtlis.serviceSend(Tools.Toenjson(new Dictionary<string, object>
|
||
{
|
||
{ "appleId", appleId },
|
||
{ "applePwd", applePwd },
|
||
{ "subscriptionId", subscriptionId },
|
||
{ "guid", guid },
|
||
{ "serviceIndex", serverIndex },
|
||
{ "type", "ICancelSubscription" }
|
||
}));
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
dynamic val = Tools.Todejosn<object>(httpResult.Html);
|
||
if (val["Code"] == "0000")
|
||
{
|
||
dynamic val2 = val["Data"];
|
||
dynamic val3 = Tools.Todejosn<object>(val2);
|
||
string text = val3["msg"];
|
||
if (string.IsNullOrEmpty(text) && !isAgent)
|
||
{
|
||
return CancelSubscription(appleId, applePwd, subscriptionId, guid, serverIndex, isAgent: true);
|
||
}
|
||
if (text.Contains("网络请求失败") && !isAgent)
|
||
{
|
||
return CancelSubscription(appleId, applePwd, subscriptionId, guid, serverIndex, isAgent: true);
|
||
}
|
||
return text;
|
||
}
|
||
if (val["Code"] == "2001" && !isAgent)
|
||
{
|
||
return CancelSubscription(appleId, applePwd, subscriptionId, guid, serverIndex, isAgent: true);
|
||
}
|
||
}
|
||
if (!isAgent)
|
||
{
|
||
return CancelSubscription(appleId, applePwd, subscriptionId, guid, serverIndex, isAgent: true);
|
||
}
|
||
return "";
|
||
}
|
||
|
||
private string GetGamaInfoOld(string appleId, string applePwd, string postData, string gameUrl, string gameType, int serverIndex, ref string yzmUrl, ref string getWkUrl, bool isAgent = false)
|
||
{
|
||
HttpResult httpResult = APIUtlis.serviceSend(Tools.Toenjson(new Dictionary<string, object>
|
||
{
|
||
{ "appleId", appleId },
|
||
{ "applePwd", applePwd },
|
||
{ "postData", postData },
|
||
{ "gameUrl", gameUrl },
|
||
{ "gameType", gameType },
|
||
{ "serviceIndex", serverIndex },
|
||
{ "type", "IGetGamaInfo" }
|
||
}));
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
dynamic val = Tools.Todejosn<object>(httpResult.Html);
|
||
if (val["Code"] == "0000")
|
||
{
|
||
dynamic val2 = val["Data"];
|
||
dynamic val3 = Tools.Todejosn<object>(val2);
|
||
if (httpResult.Html.Contains("captchaModel"))
|
||
{
|
||
dynamic val4 = val3["captchaModel"];
|
||
if (val4 != null)
|
||
{
|
||
yzmUrl = val4["yzmUrl"];
|
||
getWkUrl = val4["getWkUrl"];
|
||
}
|
||
}
|
||
string obj = val3["msg"];
|
||
if (!string.IsNullOrEmpty(obj))
|
||
{
|
||
}
|
||
return obj;
|
||
}
|
||
_ = ((val["Code"] == "2001" && !isAgent) ? true : false);
|
||
}
|
||
return "";
|
||
}
|
||
|
||
public string getKbsync(string dsid, ref int serverIndex, ref string ReueId, ref string guidNow)
|
||
{
|
||
HttpResult httpResult = APIUtlis.serviceSend(Tools.Toenjson(new Dictionary<string, object>
|
||
{
|
||
{ "Dsid", dsid },
|
||
{ "type", "ksync" },
|
||
{ "serviceIndex", serverIndex }
|
||
}));
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
dynamic val = Tools.Todejosn<object>(httpResult.Html);
|
||
if (val["Code"] == "0000")
|
||
{
|
||
serverIndex = val["serverIndex"];
|
||
dynamic val2 = val["Data"];
|
||
dynamic val3 = Tools.Todejosn<object>(val2);
|
||
if ((val3 != null) && ((val3["msg"] == "0000") ? true : false))
|
||
{
|
||
ReueId = val3["reueId"];
|
||
guidNow = val3["guidNow"];
|
||
dynamic val4 = val3["kbsync"];
|
||
return val4;
|
||
}
|
||
}
|
||
}
|
||
return "";
|
||
}
|
||
|
||
public AppleItunesLogin remoteAppleLogin(string appleId, string applePwd, ref string msgReust, int isStore = 0, bool isRetry = false)
|
||
{
|
||
HttpResult itunesLogin = APIUtlis.getItunesLogin(appleId, applePwd, isStore);
|
||
if (itunesLogin.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
dynamic val = Tools.Todejosn<object>(itunesLogin.Html);
|
||
if (val["Code"] != "0000")
|
||
{
|
||
int num = 0;
|
||
bool flag;
|
||
do
|
||
{
|
||
itunesLogin = APIUtlis.getItunesLogin(appleId, applePwd, isStore);
|
||
if (itunesLogin.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
val = Tools.Todejosn<object>(itunesLogin.Html);
|
||
}
|
||
}
|
||
while ((!(flag = num < 2)) ? ((object)flag) : (flag & (val["Code"] != "0000")));
|
||
}
|
||
if (val["Code"] == "0000")
|
||
{
|
||
dynamic val2 = val["Data"];
|
||
AppleItunesLogin appleItunesLogin = Tools.Todejosn<AppleItunesLogin>(val2);
|
||
if (appleItunesLogin == null)
|
||
{
|
||
msgReust = "登录失败:#0";
|
||
return null;
|
||
}
|
||
if (!string.IsNullOrEmpty(appleItunesLogin.xtoken) && !string.IsNullOrEmpty(appleItunesLogin.ServerId) && appleItunesLogin.ServerId != "0")
|
||
{
|
||
ProxyAccountCache.addProxyIp(appleId, "");
|
||
appleItunesLogin.serverIndex = val["serverIndex"];
|
||
appleItunesLogin.account = appleId;
|
||
appleItunesLogin.pwd = applePwd;
|
||
if (isStore == 1 || isStore == 2)
|
||
{
|
||
if (AppSysConfig.ReddemStoreSeriveIndex.ContainsKey(appleId))
|
||
{
|
||
AppSysConfig.ReddemStoreSeriveIndex[appleId] = appleItunesLogin.serverIndex;
|
||
}
|
||
else
|
||
{
|
||
AppSysConfig.ReddemStoreSeriveIndex.TryAdd(appleId, appleItunesLogin.serverIndex);
|
||
}
|
||
}
|
||
return appleItunesLogin;
|
||
}
|
||
AppSysConfig.ReddemStoreSeriveIndex.TryRemove(appleId, out var _);
|
||
if ((appleItunesLogin.msg == "0000" || appleItunesLogin.msg == "失败:" || (!string.IsNullOrEmpty(appleItunesLogin.nextServerId) && appleItunesLogin.nextServerId != "0")) && !isRetry)
|
||
{
|
||
if (!string.IsNullOrEmpty(appleItunesLogin.nextServerId) && appleItunesLogin.nextServerId != "0")
|
||
{
|
||
AppleGuidManage.UpIdGuid(appleId, applePwd);
|
||
}
|
||
return remoteAppleLogin(appleId, applePwd, ref msgReust, 2, isRetry: true);
|
||
}
|
||
msgReust = appleItunesLogin.msg;
|
||
}
|
||
else
|
||
{
|
||
msgReust = val["Message"];
|
||
}
|
||
}
|
||
else
|
||
{
|
||
AppSysConfig.ReddemStoreSeriveIndex.TryRemove(appleId, out var _);
|
||
if (!isRetry)
|
||
{
|
||
return remoteAppleLogin(appleId, applePwd, ref msgReust, isStore, isRetry: true);
|
||
}
|
||
msgReust = "请求失败";
|
||
}
|
||
return null;
|
||
}
|
||
|
||
private string GetSignsapsetup(ref string serverId, ref string userAgent, ref long intptr_, ref long intPtr, ref int serverIndex)
|
||
{
|
||
int num = 0;
|
||
dynamic val2;
|
||
while (true)
|
||
{
|
||
if (num < 3)
|
||
{
|
||
HttpResult httpResult = APIUtlis.serviceSend(Tools.Toenjson(new Dictionary<string, object>
|
||
{
|
||
{ "gZip", "1" },
|
||
{ "type", "GetSignsapsetup" },
|
||
{ "userAgent", userAgent }
|
||
}));
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
dynamic val = Tools.Todejosn<object>(httpResult.Html);
|
||
if (val["Code"] == "0000")
|
||
{
|
||
serverIndex = val["serverIndex"];
|
||
dynamic datasetByString = GetDatasetByString(val["Data"].ToString());
|
||
val2 = Tools.Todejosn<object>(datasetByString);
|
||
if (val2["msg"] == "0000")
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
Thread.Sleep(1000);
|
||
num++;
|
||
continue;
|
||
}
|
||
return "";
|
||
}
|
||
string result = HttpUtility.UrlDecode(val2["signature"].ToString());
|
||
serverId = HttpUtility.UrlDecode(val2["serverId"].ToString());
|
||
userAgent = HttpUtility.UrlDecode(val2["userAgent"].ToString());
|
||
intptr_ = val2["adder1"];
|
||
intPtr = val2["adder2"];
|
||
return result;
|
||
}
|
||
|
||
private string GetFullSignsapsetu(string appleId, string applePwd, int idType, int signModel, ref string guid, ref string userAgent, ref string storedDescrption, ref string post, ref int serverIndex, ref string serverId)
|
||
{
|
||
int num = 0;
|
||
dynamic val2;
|
||
while (true)
|
||
{
|
||
if (num < 3)
|
||
{
|
||
HttpResult httpResult = APIUtlis.serviceSend(Tools.Toenjson(new Dictionary<string, object>
|
||
{
|
||
{ "appleId", appleId },
|
||
{ "applePwd", applePwd },
|
||
{ "userAgent", userAgent },
|
||
{ "guid", guid },
|
||
{ "idType", idType },
|
||
{ "signModel", signModel },
|
||
{ "type", "GetFullSignsapsetu" },
|
||
{ "gZip", "1" }
|
||
}));
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
dynamic val = Tools.Todejosn<object>(httpResult.Html);
|
||
if (val["Code"] == "0000")
|
||
{
|
||
serverIndex = val["serverIndex"];
|
||
dynamic datasetByString = GetDatasetByString(val["Data"].ToString());
|
||
val2 = Tools.Todejosn<object>(datasetByString);
|
||
if (val2["msg"] == "0000")
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
Thread.Sleep(1000);
|
||
num++;
|
||
continue;
|
||
}
|
||
return "";
|
||
}
|
||
string result = HttpUtility.UrlDecode(val2["signature"]);
|
||
serverId = HttpUtility.UrlDecode(val2["serverId"]);
|
||
userAgent = HttpUtility.UrlDecode(val2["userAgent"]);
|
||
guid = HttpUtility.UrlDecode(val2["guid"]);
|
||
storedDescrption = HttpUtility.UrlDecode(val2["StoredDescrption"]);
|
||
post = HttpUtility.UrlDecode(val2["postData"]);
|
||
return result;
|
||
}
|
||
|
||
private string GetSignsapsetupCert(string appleId, string applePwd, int idType, byte[] signSap, long intptr_, long intPtr, int serverIndex, ref string post, ref string guid)
|
||
{
|
||
string idGuid = AppleGuidManage.getIdGuid(appleId, applePwd);
|
||
if (!string.IsNullOrEmpty(idGuid))
|
||
{
|
||
applePwd = applePwd + ":{" + idGuid + "}";
|
||
}
|
||
for (int i = 0; i < 3; i++)
|
||
{
|
||
try
|
||
{
|
||
HttpResult httpResult = APIUtlis.serviceSend(Tools.Toenjson(new Dictionary<string, object>
|
||
{
|
||
{
|
||
"signSap",
|
||
HttpUtility.UrlEncode(Convert.ToBase64String(signSap))
|
||
},
|
||
{ "appleId", appleId },
|
||
{ "guid", guid },
|
||
{ "applePwd", applePwd },
|
||
{ "intptr_", intptr_ },
|
||
{ "intPtr", intPtr },
|
||
{ "idType", idType },
|
||
{ "gZip", "1" },
|
||
{ "type", "GetSignsapsetupCert" },
|
||
{ "serviceIndex", serverIndex }
|
||
}));
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
dynamic val = Tools.Todejosn<object>(httpResult.Html);
|
||
if (val["Code"] == "0000")
|
||
{
|
||
dynamic datasetByString = GetDatasetByString(val["Data"].ToString());
|
||
dynamic val2 = Tools.Todejosn<object>(datasetByString);
|
||
string text = val2["msg"];
|
||
if (text == "0000")
|
||
{
|
||
string result = HttpUtility.UrlDecode(val2["signature"].ToString());
|
||
post = HttpUtility.UrlDecode(val2["post"].ToString());
|
||
guid = HttpUtility.UrlDecode(val2["guid"].ToString());
|
||
return result;
|
||
}
|
||
if (text.Contains("重试") || text.Contains("失败"))
|
||
{
|
||
return "retry";
|
||
}
|
||
}
|
||
}
|
||
}
|
||
catch (Exception)
|
||
{
|
||
}
|
||
Thread.Sleep(1000);
|
||
}
|
||
return "";
|
||
}
|
||
|
||
private byte[] GetSignSapSetup(byte[] postData, string userAgent, string StoredDescrption, string serverId, ref string msgReust)
|
||
{
|
||
string url = "https://play.itunes.apple.com/WebObjects/MZPlay.woa/wa/signSapSetup";
|
||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||
dictionary.Add("X-Apple-Store-Front", StoredDescrption);
|
||
try
|
||
{
|
||
HttpResult httpResult = postLoginWebContext(url, postData, "", userAgent, null, serverId, dictionary);
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
return Encoding.UTF8.GetBytes(httpResult.Html);
|
||
}
|
||
if (httpResult.StatusCode == HttpStatusCode.InternalServerError)
|
||
{
|
||
return Encoding.UTF8.GetBytes("retry");
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
msgReust = ex.Message;
|
||
APIUtlis.ApiSeriveError(ex);
|
||
}
|
||
return null;
|
||
}
|
||
|
||
public AppleItunesLogin briefAppleLogin(string appleId, string applePwd, int type, ref string msgReust, out bool isAppleSuccess, string notityKey)
|
||
{
|
||
isAppleSuccess = false;
|
||
string guid = "19eaa2036eb5d13b90b13886e2afa9ab79df867f";
|
||
string userAgent = AppSysConfig.getConfig("iTunesUserAgent");
|
||
string storedDescrption = "143465-19,17";
|
||
if (AppSysConfig.DoubleGuid.ContainsKey(appleId))
|
||
{
|
||
guid = AppSysConfig.DoubleGuid[appleId];
|
||
}
|
||
if (AppSysConfig.ReddemVerifyGuid.ContainsKey(appleId))
|
||
{
|
||
guid = AppSysConfig.ReddemVerifyGuid[appleId];
|
||
}
|
||
string post = "";
|
||
int serverIndex = 0;
|
||
string serverId = "0";
|
||
int signModel = Tools.ToInt(AppSysConfig.getConfig("getSignModel"), 2);
|
||
string fullSignsapsetu = GetFullSignsapsetu(appleId, applePwd, type, signModel, ref guid, ref userAgent, ref storedDescrption, ref post, ref serverIndex, ref serverId);
|
||
action?.Invoke(notityKey, DisplyType.xinxi, "正在登录 .");
|
||
if (post != null && fullSignsapsetu != null)
|
||
{
|
||
int num = 0;
|
||
do
|
||
{
|
||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||
dictionary.Add("X-Apple-ActionSignature", fullSignsapsetu);
|
||
dictionary.Add("X-Apple-Store-Front", storedDescrption);
|
||
string text = "https://p" + serverId + "-buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/authenticate?Pod=" + serverId + "&PRH=" + serverId;
|
||
if (serverId == "0")
|
||
{
|
||
text = "https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/authenticate";
|
||
}
|
||
HttpResult httpResult = postLoginWebContext(text, Encoding.UTF8.GetBytes(post), text, userAgent, null, serverId, dictionary);
|
||
if (httpResult.StatusCode != HttpStatusCode.TemporaryRedirect && httpResult.StatusCode != HttpStatusCode.TemporaryRedirect && httpResult.StatusCode != HttpStatusCode.Found)
|
||
{
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
isAppleSuccess = true;
|
||
string html = httpResult.Html;
|
||
string keyValue = GetKeyValue("<key>dialogId</key>", "<string>", "</string>", html);
|
||
GetKeyValue("<key>failureType</key>", "<string>", "</string>", html);
|
||
string text2 = GetKeyValue("<key>customerMessage</key>", "<string>", "</string>", html);
|
||
string keyValue2 = GetKeyValue("<key>explanation</key>", "<string>", "</string>", html);
|
||
if (keyValue == "MZFinance.DisabledAndFraudLocked")
|
||
{
|
||
msgReust = "账号已被锁定";
|
||
return null;
|
||
}
|
||
if (html.Contains("密码不正确"))
|
||
{
|
||
msgReust = "账号密码错误,或者需要输入验证码";
|
||
return null;
|
||
}
|
||
if (keyValue == "MZFinance.AccountDisabled")
|
||
{
|
||
if (!string.IsNullOrEmpty(keyValue2))
|
||
{
|
||
text2 = keyValue2;
|
||
}
|
||
msgReust = "登录失败:" + text2;
|
||
return null;
|
||
}
|
||
if (text2.Length > 0)
|
||
{
|
||
msgReust = "登录失败:" + text2;
|
||
return null;
|
||
}
|
||
string text3 = httpResult.Header["x-set-apple-store-front"];
|
||
if (!string.IsNullOrEmpty(text3))
|
||
{
|
||
storedDescrption = text3;
|
||
}
|
||
if (html.Contains("authenticateFailure"))
|
||
{
|
||
msgReust = "登录失败#2";
|
||
return null;
|
||
}
|
||
AppleItunesLogin appleItunesLogin = new AppleItunesLogin();
|
||
appleItunesLogin.account = appleId;
|
||
appleItunesLogin.pwd = applePwd;
|
||
appleItunesLogin.cookis = ConveCookle(httpResult.Cookie);
|
||
appleItunesLogin.dsis = GetKeyValue("<key>dsPersonId</key>", "<string>", "</string>", html);
|
||
appleItunesLogin.Balance = GetKeyValue("<key>creditDisplay</key>", "<string>", "</string>", html);
|
||
if (string.IsNullOrEmpty(appleItunesLogin.Balance))
|
||
{
|
||
appleItunesLogin.Balance = "0";
|
||
}
|
||
appleItunesLogin.xtoken = GetKeyValue("<key>passwordToken</key>", "<string>", "</string>", html);
|
||
appleItunesLogin.isDisabledAccount = GetKeyValue("<key>isDisabledAccount</key>", "<", "/>", html);
|
||
if (!string.IsNullOrEmpty(appleItunesLogin.xtoken))
|
||
{
|
||
string text4 = "";
|
||
string[] array = AppSysConfig.getConfig("loginExtensions").Split('|');
|
||
foreach (string text5 in array)
|
||
{
|
||
if (string.IsNullOrEmpty(text5))
|
||
{
|
||
continue;
|
||
}
|
||
string[] array2 = text5.Split(',');
|
||
if (array2.Length == 3)
|
||
{
|
||
string text6 = array2[0].Trim();
|
||
string text7 = array2[1].Trim();
|
||
string value = array2[2].Trim();
|
||
if (GetKeyValue("<key>" + text6 + "</key>", "<", "/>", html).ToLower().Contains(value))
|
||
{
|
||
text4 = text4 + text7 + ",";
|
||
}
|
||
}
|
||
}
|
||
appleItunesLogin.extension = text4.TrimEnd(',');
|
||
if (serverId == "0" || string.IsNullOrEmpty(serverId))
|
||
{
|
||
if (httpResult.Header.AllKeys.Contains("itspod"))
|
||
{
|
||
serverId = httpResult.Header["itspod"];
|
||
}
|
||
else if (httpResult.Header.AllKeys.Contains("pod"))
|
||
{
|
||
serverId = httpResult.Header["pod"];
|
||
}
|
||
}
|
||
appleItunesLogin.ServerId = serverId;
|
||
appleItunesLogin.software = storedDescrption;
|
||
appleItunesLogin.Guid = guid;
|
||
appleItunesLogin.Headers["User-Agent"] = userAgent;
|
||
appleItunesLogin.Area = AppleUtlis.GetAreaByDescription(storedDescrption);
|
||
appleItunesLogin.msg = "0000";
|
||
appleItunesLogin.serverIndex = serverIndex;
|
||
appleItunesLogin.proxyIp = base.ProxyIp;
|
||
return appleItunesLogin;
|
||
}
|
||
msgReust = "登录失败#3";
|
||
return null;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
action?.Invoke(notityKey, DisplyType.xinxi, "正在登录 ...");
|
||
serverId = GetServerId(httpResult.RedirectUrl);
|
||
}
|
||
num++;
|
||
}
|
||
while (num < 4);
|
||
msgReust = "登录失败";
|
||
return null;
|
||
}
|
||
msgReust = "登录请求失败";
|
||
return null;
|
||
}
|
||
|
||
public string GetMGuid2(string deviceAndToken)
|
||
{
|
||
if (!string.IsNullOrEmpty(deviceAndToken.Trim()))
|
||
{
|
||
return GetUid(deviceAndToken + "|888888");
|
||
}
|
||
StringBuilder stringBuilder = new StringBuilder();
|
||
int num = 7;
|
||
for (int i = 0; i < num; i++)
|
||
{
|
||
stringBuilder.Append(Guid.NewGuid().ToString().Substring(0, 8)
|
||
.ToUpper());
|
||
if (i != num - 1)
|
||
{
|
||
stringBuilder.Append(".");
|
||
}
|
||
}
|
||
return stringBuilder.ToString();
|
||
}
|
||
|
||
private static string GetUid(string readstr)
|
||
{
|
||
byte[] bytes = Encoding.Default.GetBytes(readstr);
|
||
return BitConverter.ToString(SHA1.Create().ComputeHash(bytes)).Replace("-", "").ToLower();
|
||
}
|
||
|
||
public string GetMGuid(string deviceAndToken)
|
||
{
|
||
if (!string.IsNullOrEmpty(deviceAndToken.Trim()))
|
||
{
|
||
return GetUid(deviceAndToken + "|888888");
|
||
}
|
||
return GetUid(new Random().Next(10000000, 999999999) + GetMGuid2(deviceAndToken));
|
||
}
|
||
|
||
public static string getIndeedApplePwd(string applePwd)
|
||
{
|
||
try
|
||
{
|
||
string text = "";
|
||
if (applePwd.Contains(":{"))
|
||
{
|
||
string value = new Regex(":{([\\s\\S]*?)}").Match(applePwd).Groups[1].Value;
|
||
if (!string.IsNullOrEmpty(value))
|
||
{
|
||
text = value;
|
||
applePwd = applePwd.Replace(":{" + value + "}", "");
|
||
}
|
||
}
|
||
if (applePwd.Length <= 8)
|
||
{
|
||
return applePwd;
|
||
}
|
||
if (applePwd.Length >= 14 && int.TryParse(applePwd.Substring(applePwd.Length - 6), out var _))
|
||
{
|
||
return applePwd.Substring(0, applePwd.Length - 6) + text;
|
||
}
|
||
return applePwd + text;
|
||
}
|
||
catch (Exception)
|
||
{
|
||
return applePwd;
|
||
}
|
||
}
|
||
|
||
public byte[] GetLoginSignSapSetup(string storedDescrption, ref string serverId, ref string userAgent, ref long intptr_, ref long intPtr, ref int serverAppIndex, ref string msgReust, int agentCount = 0)
|
||
{
|
||
string signsapsetup = GetSignsapsetup(ref serverId, ref userAgent, ref intptr_, ref intPtr, ref serverAppIndex);
|
||
if (string.IsNullOrEmpty(signsapsetup))
|
||
{
|
||
msgReust = "请求失败#1";
|
||
return null;
|
||
}
|
||
byte[] signSapSetup = GetSignSapSetup(Convert.FromBase64String(signsapsetup), userAgent, storedDescrption, serverId, ref msgReust);
|
||
if (signSapSetup == null)
|
||
{
|
||
if (string.IsNullOrEmpty(msgReust))
|
||
{
|
||
msgReust = "登录数据加载失败#2";
|
||
}
|
||
return null;
|
||
}
|
||
if (signSapSetup.Length == 5)
|
||
{
|
||
if (agentCount < 2)
|
||
{
|
||
return GetLoginSignSapSetup(storedDescrption, ref serverId, ref userAgent, ref intptr_, ref intPtr, ref serverAppIndex, ref msgReust, agentCount + 1);
|
||
}
|
||
if (string.IsNullOrEmpty(msgReust))
|
||
{
|
||
msgReust = "登录数据加载失败#3";
|
||
return null;
|
||
}
|
||
}
|
||
return signSapSetup;
|
||
}
|
||
|
||
public AppleItunesLogin fullAppleLogin(string appleId, string loginApplePwd, string doublePwd, int type, ref string msgReust, out bool isAppleSuccess, string notityKey, bool isRetry = false, string preinstallServerId = "")
|
||
{
|
||
isAppleSuccess = false;
|
||
string text = loginApplePwd;
|
||
if (!string.IsNullOrEmpty(doublePwd))
|
||
{
|
||
text = loginApplePwd + doublePwd;
|
||
}
|
||
string serverId = "";
|
||
string userAgent = AppSysConfig.getConfig("newiTunesUserAgent");
|
||
string text2 = "143465-19,17";
|
||
long intptr_ = 0L;
|
||
long intPtr = 0L;
|
||
int serverAppIndex = -1;
|
||
if (string.IsNullOrEmpty(notityKey))
|
||
{
|
||
notityKey = appleId;
|
||
}
|
||
base.appleId = notityKey;
|
||
string guid = "";
|
||
if (AppSysConfig.DoubleGuid.ContainsKey(appleId))
|
||
{
|
||
guid = AppSysConfig.DoubleGuid[appleId];
|
||
}
|
||
if (AppSysConfig.ReddemVerifyGuid.ContainsKey(appleId))
|
||
{
|
||
guid = AppSysConfig.ReddemVerifyGuid[appleId];
|
||
}
|
||
action?.Invoke(notityKey, DisplyType.xinxi, "正在登录 .");
|
||
string post = "";
|
||
string text3 = "";
|
||
if (AppSysConfig.getConfig("isAddsignsapsetup") == "1")
|
||
{
|
||
bool flag = false;
|
||
do
|
||
{
|
||
byte[] loginSignSapSetup = GetLoginSignSapSetup(text2, ref serverId, ref userAgent, ref intptr_, ref intPtr, ref serverAppIndex, ref msgReust);
|
||
if (loginSignSapSetup != null)
|
||
{
|
||
text3 = GetSignsapsetupCert(appleId, text, type, loginSignSapSetup, intptr_, intPtr, serverAppIndex, ref post, ref guid);
|
||
flag = (((text3 == "retry" || string.IsNullOrEmpty(text3)) && !flag) ? true : false);
|
||
Array.Clear(loginSignSapSetup, 0, loginSignSapSetup.Length);
|
||
continue;
|
||
}
|
||
return null;
|
||
}
|
||
while (flag);
|
||
if (text3 == "retry" || string.IsNullOrEmpty(text3))
|
||
{
|
||
msgReust = "登录失败:" + text3;
|
||
return null;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (string.IsNullOrEmpty(guid))
|
||
{
|
||
string text4 = Tools.GetMD5_32(AppSysConfig.saffMac + "by六月的风") + "|" + Tools.GetMD5_32(AppSysConfig.userName);
|
||
string idGuid = AppleGuidManage.getIdGuid(appleId, text);
|
||
text4 = appleId + getIndeedApplePwd(text) + idGuid + "|" + text4;
|
||
guid = GetMGuid2(text4);
|
||
}
|
||
post = string.Format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>appleId</key>\n\t<string>{1}</string>\n\t<key>attempt</key>\n\t<string>1</string>\n\t<key>createSession</key>\n\t<true/>\n\t<key>guid</key>\n\t<string>{0}</string>\n\t<key>password</key>\n\t<string>{2}</string>\n\t<key>why</key>\n\t<string>purchase</string>\n</dict>\n</plist>\n", guid, appleId, text);
|
||
}
|
||
serverId = "0";
|
||
if (!string.IsNullOrEmpty(preinstallServerId) && isRetry)
|
||
{
|
||
serverId = preinstallServerId;
|
||
}
|
||
if (post != null)
|
||
{
|
||
int num = 0;
|
||
do
|
||
{
|
||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||
if (!string.IsNullOrEmpty(text3))
|
||
{
|
||
dictionary.Add("X-Apple-ActionSignature", text3);
|
||
}
|
||
dictionary.Add("X-Apple-Store-Front", text2);
|
||
string text5 = "https://p" + serverId + "-buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/authenticate?Pod=" + serverId + "&PRH=" + serverId;
|
||
if (serverId == "0")
|
||
{
|
||
text5 = "https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/authenticate";
|
||
}
|
||
HttpResult httpResult = postLoginWebContext(text5, Encoding.UTF8.GetBytes(post), text5, userAgent, null, serverId, dictionary);
|
||
if (httpResult.StatusCode != HttpStatusCode.TemporaryRedirect && httpResult.StatusCode != HttpStatusCode.TemporaryRedirect && httpResult.StatusCode != HttpStatusCode.Found)
|
||
{
|
||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
isAppleSuccess = true;
|
||
string html = httpResult.Html;
|
||
string keyValue = GetKeyValue("<key>dialogId</key>", "<string>", "</string>", html);
|
||
string keyValue2 = GetKeyValue("<key>failureType</key>", "<string>", "</string>", html);
|
||
string text6 = GetKeyValue("<key>customerMessage</key>", "<string>", "</string>", html);
|
||
string keyValue3 = GetKeyValue("<key>explanation</key>", "<string>", "</string>", html);
|
||
string keyValue4 = GetKeyValue("<key>passwordToken</key>", "<string>", "</string>", html);
|
||
if (keyValue == "MZFinance.DisabledAndFraudLocked")
|
||
{
|
||
msgReust = "账号已被锁定";
|
||
return null;
|
||
}
|
||
if (keyValue2 == "-5000" && !string.IsNullOrEmpty(serverId) && serverId != "0" && string.IsNullOrEmpty(keyValue4) && !isRetry && Tools.ToInt(serverId, 0) > 0)
|
||
{
|
||
string[] array = AppSysConfig.getConfig("UpIdGuidKeyWork").Split('|');
|
||
foreach (string value in array)
|
||
{
|
||
if (text6.Contains(value))
|
||
{
|
||
AppleGuidManage.UpIdGuid(appleId, text);
|
||
return fullAppleLogin(appleId, loginApplePwd, doublePwd, type, ref msgReust, out isAppleSuccess, notityKey, isRetry: true, serverId);
|
||
}
|
||
}
|
||
}
|
||
if (html.Contains("密码不正确"))
|
||
{
|
||
msgReust = "账号密码错误或者需要输入双重验证码";
|
||
return null;
|
||
}
|
||
if (keyValue == "MZFinance.AccountDisabled")
|
||
{
|
||
if (!string.IsNullOrEmpty(keyValue3))
|
||
{
|
||
text6 = keyValue3;
|
||
}
|
||
msgReust = "登录失败:" + text6;
|
||
return null;
|
||
}
|
||
if (serverId == "0" || string.IsNullOrEmpty(serverId))
|
||
{
|
||
if (httpResult.Header.AllKeys.Contains("itspod"))
|
||
{
|
||
serverId = httpResult.Header["itspod"];
|
||
}
|
||
else if (httpResult.Header.AllKeys.Contains("pod"))
|
||
{
|
||
serverId = httpResult.Header["pod"];
|
||
}
|
||
}
|
||
if (keyValue == "MZFinance.AccountConversion" && (msgReust == "Overcheck" || msgReust == "OvercheckAgent"))
|
||
{
|
||
string keyValue5 = GetKeyValue("<key>url</key>", "<string>", "</string>", html);
|
||
if (Tools.ToNetWorkInt(ConfigUtlis.getConfigValue("comNetworkConfig"), 0) == 0 && openVpn)
|
||
{
|
||
if (msgReust != "OvercheckAgent")
|
||
{
|
||
if (!ActivateiTunes(keyValue5, httpResult.Cookie, userAgent, guid, text3, ref msgReust))
|
||
{
|
||
string[] array2 = AppSysConfig.getConfig("OvercheckAgentKey").Split(',');
|
||
bool flag2 = false;
|
||
string[] array = array2;
|
||
foreach (string value2 in array)
|
||
{
|
||
if (!string.IsNullOrEmpty(value2) && msgReust.Contains(value2))
|
||
{
|
||
flag2 = true;
|
||
break;
|
||
}
|
||
}
|
||
if (flag2)
|
||
{
|
||
msgReust = "OvercheckAgent";
|
||
action?.Invoke(appleId, DisplyType.error, "重试中");
|
||
ActivateiTunesRemove(appleId, loginApplePwd, userAgent, guid, serverId, keyValue5, httpResult.Cookie, ref msgReust);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
ActivateiTunesRemove(appleId, loginApplePwd, userAgent, guid, serverId, keyValue5, httpResult.Cookie, ref msgReust);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
ActivateiTunesRemove(appleId, loginApplePwd, userAgent, guid, serverId, keyValue5, httpResult.Cookie, ref msgReust);
|
||
}
|
||
return null;
|
||
}
|
||
if (text6.Length > 0)
|
||
{
|
||
msgReust = "登录失败:" + text6;
|
||
return null;
|
||
}
|
||
string text7 = httpResult.Header["x-set-apple-store-front"];
|
||
if (!string.IsNullOrEmpty(text7))
|
||
{
|
||
text2 = text7;
|
||
}
|
||
if (html.Contains("authenticateFailure"))
|
||
{
|
||
msgReust = "登录失败#2";
|
||
return null;
|
||
}
|
||
AppleItunesLogin appleItunesLogin = new AppleItunesLogin();
|
||
appleItunesLogin.account = appleId;
|
||
appleItunesLogin.pwd = text;
|
||
appleItunesLogin.cookis = ConveCookle(httpResult.Cookie);
|
||
appleItunesLogin.dsis = GetKeyValue("<key>dsPersonId</key>", "<string>", "</string>", html);
|
||
appleItunesLogin.Balance = GetKeyValue("<key>creditDisplay</key>", "<string>", "</string>", html);
|
||
if (string.IsNullOrEmpty(appleItunesLogin.Balance))
|
||
{
|
||
appleItunesLogin.Balance = "0";
|
||
}
|
||
appleItunesLogin.xtoken = GetKeyValue("<key>passwordToken</key>", "<string>", "</string>", html);
|
||
if (!string.IsNullOrEmpty(appleItunesLogin.xtoken))
|
||
{
|
||
appleItunesLogin.isDisabledAccount = GetKeyValue("<key>isDisabledAccount</key>", "<", "/>", html);
|
||
string text8 = "";
|
||
string[] array = AppSysConfig.getConfig("loginExtensions").Split('|');
|
||
foreach (string text9 in array)
|
||
{
|
||
if (string.IsNullOrEmpty(text9))
|
||
{
|
||
continue;
|
||
}
|
||
string[] array3 = text9.Split(',');
|
||
if (array3.Length == 3)
|
||
{
|
||
string text10 = array3[0].Trim();
|
||
string text11 = array3[1].Trim();
|
||
string value3 = array3[2].Trim();
|
||
if (GetKeyValue("<key>" + text10 + "</key>", "<", "/>", html).ToLower().Contains(value3))
|
||
{
|
||
text8 = text8 + text11 + ",";
|
||
}
|
||
}
|
||
}
|
||
appleItunesLogin.extension = text8.TrimEnd(',');
|
||
appleItunesLogin.ServerId = serverId;
|
||
appleItunesLogin.software = text2;
|
||
appleItunesLogin.Guid = guid;
|
||
appleItunesLogin.Headers["User-Agent"] = userAgent;
|
||
appleItunesLogin.Area = AppleUtlis.GetAreaByDescription(text2);
|
||
appleItunesLogin.msg = "0000";
|
||
appleItunesLogin.serverIndex = serverAppIndex;
|
||
appleItunesLogin.proxyIp = base.ProxyIp;
|
||
ProxyAccountCache.addProxyIp(appleItunesLogin.account, base.ProxyIp);
|
||
return appleItunesLogin;
|
||
}
|
||
msgReust = "登录失败#3";
|
||
return null;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
action?.Invoke(notityKey, DisplyType.xinxi, "正在登录 ...");
|
||
serverId = GetServerId(httpResult.RedirectUrl);
|
||
}
|
||
num++;
|
||
}
|
||
while (num < 4);
|
||
msgReust = "登录失败";
|
||
return null;
|
||
}
|
||
msgReust = "登录请求失败";
|
||
return null;
|
||
}
|
||
|
||
public AppleItunesLogin appleLogin(string appleId, string applePwd, int type, ref string msgReust, out bool isAppleSuccess)
|
||
{
|
||
if (AppSysConfig.getConfig("AppleLoginModel") == "full")
|
||
{
|
||
return fullAppleLogin(appleId, applePwd, "", type, ref msgReust, out isAppleSuccess, base.notyKey);
|
||
}
|
||
return briefAppleLogin(appleId, applePwd, type, ref msgReust, out isAppleSuccess, base.notyKey);
|
||
}
|
||
|
||
public static string GetDatasetByString(string Value)
|
||
{
|
||
return GZipDecompressString(Value);
|
||
}
|
||
|
||
public static string GZipDecompressString(string zippedString)
|
||
{
|
||
if (!string.IsNullOrEmpty(zippedString) && zippedString.Length != 0)
|
||
{
|
||
byte[] zippedData = Convert.FromBase64String(zippedString.ToString());
|
||
return Encoding.UTF8.GetString(Decompress(zippedData));
|
||
}
|
||
return "";
|
||
}
|
||
|
||
public static byte[] Decompress(byte[] zippedData)
|
||
{
|
||
GZipStream gZipStream = new GZipStream(new MemoryStream(zippedData), CompressionMode.Decompress);
|
||
MemoryStream memoryStream = new MemoryStream();
|
||
byte[] array = new byte[1024];
|
||
while (true)
|
||
{
|
||
int num = gZipStream.Read(array, 0, array.Length);
|
||
if (num <= 0)
|
||
{
|
||
break;
|
||
}
|
||
memoryStream.Write(array, 0, num);
|
||
}
|
||
gZipStream.Close();
|
||
return memoryStream.ToArray();
|
||
}
|
||
|
||
public string GetServerId(string UrlValue)
|
||
{
|
||
int num = UrlValue.IndexOf("https://p", StringComparison.InvariantCulture);
|
||
string text = UrlValue.Substring(num + "https://p".Length);
|
||
num = text.IndexOf("-buy");
|
||
if (num >= 0)
|
||
{
|
||
text = text.Substring(0, num);
|
||
}
|
||
if (long.TryParse(text, out var result))
|
||
{
|
||
return result.ToString();
|
||
}
|
||
return "0".ToString();
|
||
}
|
||
}
|
||
}
|