mirror of
https://git.oceanpay.cc/danial/kami_itunes_june.git
synced 2025-12-18 21:21:34 +00:00
1207 lines
48 KiB
C#
1207 lines
48 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Reflection;
|
|
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.AppleWebServace
|
|
{
|
|
public class AppleShopWeb : AppleWebBase
|
|
{
|
|
protected string Apple_Widget_Key = "a797929d224abb1cc663bb187bbcd02f7172ca3a84df470380522a7c6092118b";
|
|
|
|
private AppleAcount acount;
|
|
|
|
public string homeLanguage = "zh_CN";
|
|
|
|
private AuthsigninConfig authsigninConfig;
|
|
|
|
private string initAreaCode = "";
|
|
|
|
private static readonly object lockHas2hObj = new object();
|
|
|
|
protected string iframeId { get; set; }
|
|
|
|
public string DomainId { get; set; } = "21";
|
|
|
|
|
|
public string appleId { get; set; }
|
|
|
|
public string redirectURI { get; set; } = "";
|
|
|
|
|
|
public string authUrl { get; set; } = "https://www.apple.com/";
|
|
|
|
|
|
public string Apple_ID_Account_Country { get; set; } = "";
|
|
|
|
|
|
public string signInURL { get; set; } = string.Empty;
|
|
|
|
|
|
public AppleShopWeb(bool _openVpn, string _notifiKey, Action<string, DisplyType, string> _action, Action<string, DisplyType, string> _applyAtion, ITaskRunState _taskState)
|
|
: base(_action, _applyAtion, _taskState)
|
|
{
|
|
base.noticeKey = _notifiKey;
|
|
taskState = _taskState ?? throw new Exception("任务运行状态不能是空的");
|
|
base.openVpn = _openVpn;
|
|
iframeId = APPLEHCHelp.getIframeId();
|
|
authsigninConfig = new AuthsigninConfig
|
|
{
|
|
Apple_Widget_Key = Apple_Widget_Key,
|
|
authUrl = authUrl,
|
|
homeLanguage = homeLanguage,
|
|
iframeId = iframeId,
|
|
redirectURI = authUrl,
|
|
refererUrl = "https://idmsa.apple.com/"
|
|
};
|
|
}
|
|
|
|
public bool InitAreaCode(AppleAcount _acount)
|
|
{
|
|
if (string.IsNullOrEmpty(base.ProxyIp))
|
|
{
|
|
base.ProxyIp = ProxyAccountCache.getProxyAccountIP(acount.appleId);
|
|
}
|
|
if (string.IsNullOrEmpty(initAreaCode))
|
|
{
|
|
listCookie.Add(new CookieItem
|
|
{
|
|
Key = "geo",
|
|
Value = "CN"
|
|
});
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "正在获取ID国家....");
|
|
string errMsg = "";
|
|
HttpResult result = null;
|
|
if (authsignin(acount.appleId, acount.applePwd, authsigninConfig, ref errMsg, out result))
|
|
{
|
|
string[] allKeys;
|
|
if (result.StatusCode == HttpStatusCode.PreconditionFailed)
|
|
{
|
|
allKeys = result.Header.AllKeys;
|
|
foreach (string text in allKeys)
|
|
{
|
|
switch (text)
|
|
{
|
|
case "X-Apple-Auth-Attributes":
|
|
case "X-Apple-Repair-Session-Token":
|
|
case "X-Apple-ID-Session-Id":
|
|
case "scnt":
|
|
case "X-Apple-OAuth-Context":
|
|
handelDic.TryAddDic(text, result.Header[text]);
|
|
break;
|
|
}
|
|
if (text == "scnt")
|
|
{
|
|
handelDic.TryAddDic("scnt2", result.Header[text]);
|
|
}
|
|
}
|
|
baseRepair(acount.appleId, authsigninConfig);
|
|
}
|
|
if ((result.StatusCode == HttpStatusCode.PreconditionFailed || result.StatusCode == HttpStatusCode.Conflict || result.StatusCode == HttpStatusCode.OK) && result.Header.AllKeys.Contains("X-Apple-ID-Account-Country"))
|
|
{
|
|
Apple_ID_Account_Country = result.Header["X-Apple-ID-Account-Country"].ToString();
|
|
action?.Invoke(base.noticeKey, DisplyType.area, AppleUtlis.GetAreaByCode(Apple_ID_Account_Country));
|
|
}
|
|
string apple_ID_Account_Country = Apple_ID_Account_Country;
|
|
initAreaCode = AppleUtlis.GetAreaCodeByCode(apple_ID_Account_Country);
|
|
allKeys = AppSysConfig.getConfig("ShopInitAreaCodeConver").Split(',');
|
|
for (int i = 0; i < allKeys.Length; i++)
|
|
{
|
|
string[] array = allKeys[i].Split('=');
|
|
if (array.Length >= 2 && initAreaCode.ToLower().Trim() == array[0].ToLower().Trim())
|
|
{
|
|
initAreaCode = array[1].Trim();
|
|
}
|
|
}
|
|
if (AppSysConfig.getConfig("ShopBanalNotSupportedCountries").Split(',').Contains(apple_ID_Account_Country))
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "该 ID 国家不支持");
|
|
return false;
|
|
}
|
|
if (result.Html.Contains("hsa2"))
|
|
{
|
|
_acount.isHsa2 = true;
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private string NowUCTFormat()
|
|
{
|
|
return DateTime.Now.ToString("yyyy/MM/dd ttHH:mm:ss");
|
|
}
|
|
|
|
public string getDate()
|
|
{
|
|
return ((DateTime.Now.ToUniversalTime().Ticks - 621355968000000000L) / 10000L).ToString();
|
|
}
|
|
|
|
public bool WebOrderQuery(string urlLink, bool agent = false)
|
|
{
|
|
try
|
|
{
|
|
HttpItem item = new HttpItem
|
|
{
|
|
URL = urlLink,
|
|
Method = "GET",
|
|
UserAgent = base.userAgent,
|
|
Cookie = listCookie.toFonmtCookie(),
|
|
Accept = "text/html",
|
|
ProtocolVersion = HttpVersion.Version11,
|
|
KeepAlive = true,
|
|
ResultType = ResultType.String,
|
|
WebProxy = WebRequest.DefaultWebProxy,
|
|
Allowautoredirect = true
|
|
};
|
|
addHander(item);
|
|
HttpResult httpReuslt = GetHttpReuslt(item);
|
|
if (httpReuslt.StatusCode == HttpStatusCode.OK)
|
|
{
|
|
string value = new Regex(AppSysConfig.getConfig("WebOrderScriptRegex")).Match(httpReuslt.Html).Groups[1].Value;
|
|
if (!string.IsNullOrEmpty(value))
|
|
{
|
|
signInURL = new Regex("signInURL\":\"([\\s\\S]*?)\"").Match(value).Groups[1].Value;
|
|
string config = AppSysConfig.getConfig("WebOrderInfoRegexs");
|
|
string value2 = "";
|
|
string value3 = "";
|
|
string value4 = "";
|
|
string value5 = "";
|
|
string value6 = "";
|
|
string text = "";
|
|
string text2 = "";
|
|
string text3 = "";
|
|
string value7 = "";
|
|
string value8 = "";
|
|
string[] array = config.Split('|');
|
|
for (int i = 0; i < array.Length; i++)
|
|
{
|
|
string[] array2 = array[i].Split('=');
|
|
if (array2.Length != 2)
|
|
{
|
|
continue;
|
|
}
|
|
string text4 = array2[0];
|
|
string pattern = array2[1];
|
|
string input = value;
|
|
if ((text4 == "firstName" || text4 == "lastName") && value.IndexOf("/abs.Shipping-address") > 0)
|
|
{
|
|
input = value.Substring(value.IndexOf("/abs.Shipping-address"));
|
|
}
|
|
string value9 = new Regex(pattern).Match(input).Groups[1].Value;
|
|
if (!string.IsNullOrEmpty(value9))
|
|
{
|
|
switch (text4)
|
|
{
|
|
case "trackingURLMap":
|
|
text3 = value9;
|
|
break;
|
|
case "currentStatus":
|
|
value2 = value9;
|
|
break;
|
|
case "lastName":
|
|
text2 = value9;
|
|
break;
|
|
case "orderPlacedDate":
|
|
value6 = value9;
|
|
break;
|
|
case "signInURL":
|
|
signInURL = value9;
|
|
break;
|
|
case "firstName":
|
|
text = value9;
|
|
break;
|
|
case "orderNumber":
|
|
value3 = value9;
|
|
break;
|
|
case "trackingType":
|
|
value7 = value9;
|
|
break;
|
|
case "deliveryDate":
|
|
value5 = value9;
|
|
break;
|
|
case "trackingOrder":
|
|
value8 = value9;
|
|
break;
|
|
case "productName":
|
|
value4 = value9;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (string.IsNullOrEmpty(value8) && !string.IsNullOrEmpty(text3))
|
|
{
|
|
string[] array3 = text3.Split(':');
|
|
value8 = array3[0].Replace("\"", "");
|
|
if (array3.Length >= 2 && text3.Contains("http"))
|
|
{
|
|
string input2 = text3.Substring(text3.IndexOf("http")).Replace("\"", "");
|
|
value7 = new Regex("\\.([\\s\\S]*?)\\.").Match(input2).Groups[1].Value.ToUpper();
|
|
}
|
|
}
|
|
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
|
dictionary.Add("currentStatus", value2);
|
|
dictionary.Add("orderNumber", value3);
|
|
dictionary.Add("productName", value4);
|
|
dictionary.Add("deliveryDate", value5);
|
|
dictionary.Add("orderPlacedDate", value6);
|
|
dictionary.Add("billName", text + " " + text2);
|
|
dictionary.Add("trackingType", value7);
|
|
dictionary.Add("trackingOrder", value8);
|
|
action?.Invoke(base.noticeKey, DisplyType.area, Tools.Toenjson(dictionary));
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "查询完成");
|
|
return true;
|
|
}
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败:数据获取失败,请确认链接是否正确。");
|
|
return false;
|
|
}
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败:订单信息获取失败[" + httpReuslt.StatusCode.ToString() + "].");
|
|
return false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
APIUtlis.ApiSeriveError(ex);
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, ex.Message);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public bool LoginWebOrderQuery(AppleAcount _acount, string refererUrl)
|
|
{
|
|
HttpResult webContent = getWebContent(signInURL, refererUrl);
|
|
HttpResult loginResult;
|
|
if (webContent.StatusCode != HttpStatusCode.Found && webContent.StatusCode != HttpStatusCode.SeeOther)
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "登录加载失败#2.");
|
|
}
|
|
else if (ShopLogin(_acount, webContent.RedirectUrl, refererUrl, out loginResult))
|
|
{
|
|
dynamic val = Tools.Todejosn<object>(loginResult.Html);
|
|
string url = val["head"]["data"]["url"];
|
|
HttpResult webContent2 = getWebContent(url, webContent.RedirectUrl);
|
|
if (webContent2.StatusCode == HttpStatusCode.OK)
|
|
{
|
|
string value = new Regex(AppSysConfig.getConfig("LoginWebOrderScriptRegex")).Match(webContent2.Html).Groups[1].Value;
|
|
if (!string.IsNullOrEmpty(value))
|
|
{
|
|
string config = AppSysConfig.getConfig("LoginWebOrderInfoRegexs");
|
|
string text = "";
|
|
string[] array = config.Split('|');
|
|
for (int i = 0; i < array.Length; i++)
|
|
{
|
|
string[] array2 = array[i].Split('=');
|
|
if (array2.Length != 2)
|
|
{
|
|
continue;
|
|
}
|
|
string text2 = array2[0];
|
|
string pattern = array2[1];
|
|
string input = value;
|
|
string value2 = new Regex(pattern).Match(input).Groups[1].Value;
|
|
if (string.IsNullOrEmpty(value2))
|
|
{
|
|
continue;
|
|
}
|
|
if (text2.Contains("_getUrl") && value2.ToLower().StartsWith("http"))
|
|
{
|
|
HttpResult webContent3 = getWebContent(value2, webContent.RedirectUrl);
|
|
if (webContent3.StatusCode != HttpStatusCode.OK)
|
|
{
|
|
continue;
|
|
}
|
|
string[] array3 = AppSysConfig.getConfig("LoginWebOrderInfoGetUrlRegexs_" + text2).Split('|');
|
|
for (int j = 0; j < array3.Length; j++)
|
|
{
|
|
string[] array4 = array3[j].Split('=');
|
|
if (array4.Length == 2)
|
|
{
|
|
string text3 = array4[0];
|
|
string value3 = new Regex(array4[1]).Match(webContent3.Html).Groups[1].Value;
|
|
if (!string.IsNullOrEmpty(value3))
|
|
{
|
|
text = text + text3 + ":" + value3 + " | ";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (!string.IsNullOrEmpty(value2))
|
|
{
|
|
text = text + text2 + ":" + value2 + " | ";
|
|
}
|
|
}
|
|
text = text.Trim().TrimEnd('|');
|
|
action?.Invoke(base.noticeKey, DisplyType.xiaofeiriqiNow, text);
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "查询完成");
|
|
return true;
|
|
}
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败:订单数据获取失败。");
|
|
return false;
|
|
}
|
|
if (webContent2.StatusCode == HttpStatusCode.SeeOther)
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败:这个Apple id与订单不匹配。");
|
|
return true;
|
|
}
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "未知异常:" + (int)webContent2.StatusCode);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public bool ShopLogin(AppleAcount _acount, string locationUrl, string refererUrl, out HttpResult loginResult, bool agent = false)
|
|
{
|
|
loginResult = null;
|
|
try
|
|
{
|
|
string text = locationUrl;
|
|
HttpResult webContent = getWebContent(locationUrl, refererUrl);
|
|
if (webContent.StatusCode == HttpStatusCode.Found || webContent.StatusCode == HttpStatusCode.SeeOther)
|
|
{
|
|
getWebContent(webContent.RedirectUrl, text);
|
|
text = webContent.RedirectUrl;
|
|
}
|
|
string value = new Regex("x-aos-stk\":\"([\\s\\S]*?)\"").Match(webContent.Html).Groups[1].Value;
|
|
if (string.IsNullOrEmpty(value))
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "登录加载失败.");
|
|
return false;
|
|
}
|
|
string refererUrl2 = text.Substring(0, text.IndexOf("/shop/"));
|
|
new Regex("apple.com/([\\s\\S]*?)shop").Match(text).Groups[1].Value.Trim();
|
|
authsigninConfig.redirectURI = refererUrl2;
|
|
string errMsg = "";
|
|
if (authsignin(_acount.appleId, _acount.applePwd, authsigninConfig, ref errMsg, out var _))
|
|
{
|
|
if (_acount.isHsa2)
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败:需要双重验证码.");
|
|
return false;
|
|
}
|
|
string postData = "deviceID=TF1%3B015%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3BMozilla%3BNetscape%3B5.0%2520%2528Windows%2520NT%252010.0%253B%2520Win64%253B%2520x64%2529%2520AppleWebKit%2F537.36%2520%2528KHTML%252C%2520like%2520Gecko%2529%2520Chrome%2F86.0.4240.183%2520Safari%2F537.36%3B20030107%3Bundefined%3Btrue%3B%3Btrue%3BWin32%3Bundefined%3BMozilla%2F5.0%2520%2528Windows%2520NT%252010.0%253B%2520Win64%253B%2520x64%2529%2520AppleWebKit%2F537.36%2520%2528KHTML%252C%2520like%2520Gecko%2529%2520Chrome%2F86.0.4240.183%2520Safari%2F537.36%3Bzh-CN%3Bundefined%3Bsecure2.store.apple.com%3Bundefined%3Bundefined%3Bundefined%3Bundefined%3Bfalse%3Bfalse%3B" + getDate() + "%3B8%3B2005%2F6%2F7%2520%25u4E0B%25u53489%253A33%253A44%3B1920%3B1080%3B%3B%3B%3B%3B%3B%3B%3B-480%3B-480%3B" + HttpUtility.UrlEncode(HttpUtility.UrlEncode(NowUCTFormat())) + "%3B24%3B1920%3B1040%3B0%3B0%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B25%3B&&grantCode=";
|
|
WebHeaderCollection webHeaderCollection = new WebHeaderCollection
|
|
{
|
|
{ "syntax", "graviton" },
|
|
{ "X-Requested-With", "Fetch" },
|
|
{ "modelVersion", "v2" }
|
|
};
|
|
webHeaderCollection.Add("x-aos-stk", value);
|
|
webHeaderCollection.Add("x-aos-model-page", "signInPage");
|
|
string text2 = text.Replace("signIn", "signIn/idms/authx");
|
|
if (text.Contains("signIn"))
|
|
{
|
|
Uri uri = new Uri(text);
|
|
string oldValue = uri.AbsolutePath.Substring(uri.AbsolutePath.IndexOf("signIn"));
|
|
text2 = text.Replace(oldValue, "signIn/idms/authx");
|
|
}
|
|
HttpResult httpResult = postWebContent(text2 + "&up=true", postData, text, webHeaderCollection, "application/json, text/javascript, */*; q=0.01", "application/x-www-form-urlencoded");
|
|
if (httpResult.StatusCode == HttpStatusCode.OK)
|
|
{
|
|
if (httpResult.Html.Contains("shop/signIn"))
|
|
{
|
|
if (!agent)
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "商城登录失败..重新登录");
|
|
return ShopLogin(acount, locationUrl, refererUrl2, out loginResult, agent: true);
|
|
}
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "商城登录失败..请重试");
|
|
return false;
|
|
}
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "登录成功");
|
|
loginResult = httpResult;
|
|
return true;
|
|
}
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "商城页面登录失败");
|
|
if (!agent)
|
|
{
|
|
return ShopLogin(acount, locationUrl, refererUrl2, out loginResult, agent: true);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
APIUtlis.ApiSeriveError(ex);
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, ex.Message);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public bool AppleQueryStoreBalance(AppleAcount _acount, Func<string, int, string> actGetCode, bool agent = false)
|
|
{
|
|
acount = _acount;
|
|
appleId = acount.appleId;
|
|
string errMsg = "";
|
|
HttpResult result = null;
|
|
if (!InitAreaCode(_acount))
|
|
{
|
|
return false;
|
|
}
|
|
if (actGetCode == null && _acount.isHsa2)
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败:需要双重验证码.");
|
|
return false;
|
|
}
|
|
string text = initAreaCode;
|
|
if (string.IsNullOrEmpty(base.ProxyIp))
|
|
{
|
|
base.ProxyIp = ProxyAccountCache.getProxyAccountIP(acount.appleId);
|
|
}
|
|
listCookie.Clear();
|
|
handelDic.Clear();
|
|
iframeId = APPLEHCHelp.getIframeId();
|
|
authsigninConfig.iframeId = iframeId;
|
|
listCookie.Clear();
|
|
handelDic.Clear();
|
|
try
|
|
{
|
|
text = ((!(text == "us")) ? (text + "/") : "");
|
|
string text2 = "https://www.apple.com/" + text + "shop/";
|
|
WebHeaderCollection webHeaderCollection = new WebHeaderCollection
|
|
{
|
|
{ "Sec-Fetch-Site", "same-origin" },
|
|
{ "Sec-Fetch-Mode", "navigate" },
|
|
{ "Sec-Fetch-Dest", "document" },
|
|
{ "Sec-Fetch-User", "?1" }
|
|
};
|
|
webHeaderCollection.Add("X-Apple-Frame-Id", iframeId);
|
|
webHeaderCollection.Add("X-Apple-I-FD-Client-Info", FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent));
|
|
HttpResult webContent = getWebContent(text2 + "watch/bands", text2 + "watch/bands", webHeaderCollection);
|
|
if (webContent.StatusCode == HttpStatusCode.MovedPermanently)
|
|
{
|
|
text = new Regex("apple.com/([\\s\\S]*?)shop").Match(webContent.RedirectUrl).Groups[1].Value.Trim();
|
|
text2 = "https://www.apple.com/" + text + "shop/";
|
|
webContent = getWebContent(webContent.RedirectUrl, text2 + "watch/bands", webHeaderCollection);
|
|
}
|
|
if (webContent.Html.Contains("document.cookie"))
|
|
{
|
|
string cookies = new Regex("document.cookie([\\s\\S]*?)path=").Match(webContent.Html).Groups[1].Value.Trim().TrimStart('=').Trim()
|
|
.TrimStart('"')
|
|
.TrimEnd(';');
|
|
addCookle(cookies);
|
|
}
|
|
AppSysConfig.getConfig("partNumberRegex");
|
|
string pattern = "\"partNumber\":\"([\\s\\S]*?)\"";
|
|
int num = Tools.ToInt(AppSysConfig.getConfig("partNumberStartIndex"), 3);
|
|
int num2 = 0;
|
|
string text3 = "";
|
|
string text4 = "";
|
|
string text5 = "";
|
|
do
|
|
{
|
|
if (new Regex(pattern).Matches(webContent.Html).Count > num)
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "加载商品信息..." + (num2 + 1) + "..");
|
|
text4 = new Regex(pattern).Matches(webContent.Html)[num].Groups[1].Value.Trim();
|
|
AppSysConfig.getConfig("partNumberRegex");
|
|
text3 = new Regex("product/" + text4 + "([\\s\\S]*?)\"").Match(webContent.Html).Groups[0].Value.TrimEnd('"');
|
|
if (!string.IsNullOrEmpty(text3))
|
|
{
|
|
webHeaderCollection["X-Apple-I-FD-Client-Info"] = FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent);
|
|
HttpResult webContent2 = getWebContent(text2 + text3, text2 + "watch/bands", webHeaderCollection);
|
|
text5 = new Regex("fnode\",\"attrValue\":\"([\\s\\S]*?)\"").Match(webContent2.Html).Groups[1].Value.Trim();
|
|
if (!webContent2.Html.Contains("add-to-cart\",\"disabled\":true"))
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
num += 3;
|
|
num2++;
|
|
continue;
|
|
}
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "加载商品失败.");
|
|
return false;
|
|
}
|
|
while (num2 < 3);
|
|
num2 = 0;
|
|
do
|
|
{
|
|
HttpResult webContent3 = getWebContent(text2 + "beacon/atb", text2 + text3, webHeaderCollection);
|
|
if (webContent3.StatusCode != HttpStatusCode.MovedPermanently)
|
|
{
|
|
if (listCookie.Where((CookieItem c) => c.Key == "as_atb").FirstOrDefault() != null)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
text2 = webContent3.RedirectUrl.Replace("beacon/atb", "");
|
|
}
|
|
num2++;
|
|
}
|
|
while (num2 <= 3);
|
|
string text6 = Tools.ToUrlEncode(text4);
|
|
CookieItem cookieItem = listCookie.Where((CookieItem c) => c.Key == "as_atb").FirstOrDefault();
|
|
string text7 = ((cookieItem != null) ? cookieItem.Value.Split('|')[2] : null);
|
|
string postData = "product=" + text6 + "&fnode=" + text5 + "&atbtoken=" + text7;
|
|
webHeaderCollection["X-Apple-I-FD-Client-Info"] = FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent);
|
|
_ = postWebContent(text2 + "pdpAddToBag/" + text4, postData, text2 + text3, webHeaderCollection, "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", "application/x-www-form-urlencoded").StatusCode;
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "加载登录页面.");
|
|
HttpResult webContent4 = getWebContent(text2 + "bag", text2 + "bag");
|
|
bool flag2;
|
|
object obj4;
|
|
if (webContent4.StatusCode == HttpStatusCode.OK)
|
|
{
|
|
string value = new Regex("x-aos-stk\":\"([\\s\\S]*?)\"").Match(webContent4.Html).Groups[1].Value;
|
|
string value2 = new Regex("cart-items-item-([\\s\\S]*?)\"").Match(webContent4.Html).Groups[1].Value;
|
|
WebHeaderCollection webHeaderCollection2 = new WebHeaderCollection
|
|
{
|
|
{ "syntax", "graviton" },
|
|
{ "X-Requested-With", "Fetch" },
|
|
{ "modelVersion", "v2" }
|
|
};
|
|
webHeaderCollection2.Add("x-aos-stk", value);
|
|
webHeaderCollection2.Add("x-aos-model-page", "cart");
|
|
string postData2 = "shoppingCart.recommendations.recommendedItem.part=&shoppingCart.items.item-" + value2 + ".isIntentToGift=false&shoppingCart.items.item-" + value2 + ".itemQuantity.quantity=1&shoppingCart.locationConsent.locationConsent=false&shoppingCart.summary.promoCode.promoCode=&shoppingCart.actions.fcscounter=&shoppingCart.actions.fcsdata=";
|
|
HttpResult httpResult = postWebContent(text2 + "bagx/checkout_now?_a=checkout&_m=shoppingCart.actions", postData2, text2 + "bag", webHeaderCollection2, "application/json, text/javascript, */*; q=0.01", "application/x-www-form-urlencoded");
|
|
string text8 = new Regex("url\":\"([\\s\\S]*?)\"").Match(httpResult.Html).Groups[1].Value;
|
|
if (!text8.StartsWith("http"))
|
|
{
|
|
text8 = new Regex("signInUrl\":\"([\\s\\S]*?)\"").Match(httpResult.Html).Groups[1].Value;
|
|
}
|
|
HttpResult webContent5 = getWebContent(text8, text2 + "bag");
|
|
if (webContent5.StatusCode == HttpStatusCode.Found || webContent5.StatusCode == HttpStatusCode.SeeOther)
|
|
{
|
|
getWebContent(webContent5.RedirectUrl, text8);
|
|
text8 = webContent5.RedirectUrl;
|
|
}
|
|
redirectURI = text8.Substring(0, text8.IndexOf("/shop/"));
|
|
string.IsNullOrEmpty(redirectURI);
|
|
text = new Regex("apple.com/([\\s\\S]*?)shop").Match(text8).Groups[1].Value.Trim();
|
|
authsigninConfig.redirectURI = redirectURI;
|
|
if (authsignin(acount.appleId, acount.applePwd, authsigninConfig, ref errMsg, out result))
|
|
{
|
|
if (_acount.isHsa2)
|
|
{
|
|
if (actGetCode == null)
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败:需要输入双重验证码.");
|
|
return false;
|
|
}
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "等待发送验证码...");
|
|
if (!appleauthHashAuth(acount, actGetCode))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
string postData3 = "deviceID=TF1%3B015%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3BMozilla%3BNetscape%3B5.0%2520%2528Windows%2520NT%252010.0%253B%2520Win64%253B%2520x64%2529%2520AppleWebKit%2F537.36%2520%2528KHTML%252C%2520like%2520Gecko%2529%2520Chrome%2F86.0.4240.183%2520Safari%2F537.36%3B20030107%3Bundefined%3Btrue%3B%3Btrue%3BWin32%3Bundefined%3BMozilla%2F5.0%2520%2528Windows%2520NT%252010.0%253B%2520Win64%253B%2520x64%2529%2520AppleWebKit%2F537.36%2520%2528KHTML%252C%2520like%2520Gecko%2529%2520Chrome%2F86.0.4240.183%2520Safari%2F537.36%3Bzh-CN%3Bundefined%3Bsecure2.store.apple.com%3Bundefined%3Bundefined%3Bundefined%3Bundefined%3Bfalse%3Bfalse%3B" + getDate() + "%3B8%3B2005%2F6%2F7%2520%25u4E0B%25u53489%253A33%253A44%3B1920%3B1080%3B%3B%3B%3B%3B%3B%3B%3B-480%3B-480%3B" + HttpUtility.UrlEncode(HttpUtility.UrlEncode(NowUCTFormat())) + "%3B24%3B1920%3B1040%3B0%3B0%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B%3B25%3B&&grantCode=";
|
|
WebHeaderCollection webHeaderCollection3 = new WebHeaderCollection
|
|
{
|
|
{ "syntax", "graviton" },
|
|
{ "X-Requested-With", "Fetch" },
|
|
{ "modelVersion", "v2" }
|
|
};
|
|
webHeaderCollection3.Add("x-aos-stk", value);
|
|
webHeaderCollection3.Add("x-aos-model-page", "signInPage");
|
|
string text9 = text8.Replace("signIn", "signIn/idms/authx");
|
|
HttpResult httpResult2 = postWebContent(text9 + "&up=true", postData3, text8, webHeaderCollection3, "application/json, text/javascript, */*; q=0.01", "application/x-www-form-urlencoded");
|
|
if (httpResult2.StatusCode == HttpStatusCode.OK)
|
|
{
|
|
if (httpResult2.Html.Contains("shop/signIn"))
|
|
{
|
|
if (!agent)
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "商城登录失败..重新登录");
|
|
return AppleQueryStoreBalance(acount, actGetCode, agent: true);
|
|
}
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "商城登录失败..请重试");
|
|
return false;
|
|
}
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "登录成功");
|
|
dynamic val = Tools.Todejosn<object>(httpResult2.Html);
|
|
string url = val["head"]["data"]["url"];
|
|
try
|
|
{
|
|
string text10 = val["head"]["data"]["args"]["pltn"];
|
|
postData2 = "pltn=" + text10;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
postData2 = "{}";
|
|
}
|
|
WebHeaderCollection webHeader = new WebHeaderCollection
|
|
{
|
|
{ "Sec-Fetch-Site", "same-origin" },
|
|
{ "Upgrade-Insecure-Requests", "1" },
|
|
{ "Sec-Fetch-Mode", "navigate" },
|
|
{ "Sec-Fetch-Dest", "document" },
|
|
{ "Sec-Fetch-User", "?1" }
|
|
};
|
|
HttpResult httpResult3 = postWebContent(url, postData2, text8, webHeader, "application/json, text/javascript, */*; q=0.01", "application/x-www-form-urlencoded");
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "正在查询余额");
|
|
if (httpResult3.StatusCode != HttpStatusCode.Found && webContent5.StatusCode != HttpStatusCode.SeeOther)
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "查询失败");
|
|
if (!agent)
|
|
{
|
|
return AppleQueryStoreBalance(acount, actGetCode, agent: true);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
HttpResult webContent6 = getWebContent(httpResult3.RedirectUrl, text8);
|
|
if (webContent6.StatusCode == HttpStatusCode.OK)
|
|
{
|
|
string text11 = webContent6.Html;
|
|
value = new Regex("x-aos-stk\":\"([\\s\\S]*?)\"").Match(webContent6.Html).Groups[1].Value;
|
|
WebHeaderCollection webHeaderCollection4 = new WebHeaderCollection
|
|
{
|
|
{ "Sec-Fetch-Site", "same-origin" },
|
|
{ "Upgrade-Insecure-Requests", "1" },
|
|
{ "Sec-Fetch-Mode", "cors" },
|
|
{ "Sec-Fetch-Dest", "empty" },
|
|
{ "syntax", "graviton" },
|
|
{ "X-Requested-With", "Fetch" },
|
|
{ "modelVersion", "v2" }
|
|
};
|
|
webHeaderCollection4.Add("x-aos-stk", value);
|
|
webHeaderCollection4.Add("x-aos-model-page", "checkoutPage");
|
|
string value3 = new Regex("\"selectShippingOption\":\"([\\s\\S]*?)\"").Match(text11).Groups[1].Value.Trim();
|
|
NationalList nationalList = (from c in new NationalData().getMation()
|
|
where c.payment?.billingAddress?.countryCode == Apple_ID_Account_Country
|
|
select c).FirstOrDefault();
|
|
if (string.IsNullOrEmpty(value3))
|
|
{
|
|
text11 = SelectShippingOptionNullData(text11, nationalList, redirectURI, webHeaderCollection4);
|
|
}
|
|
value3 = new Regex("\"selectShippingOption\":\"([\\s\\S]*?)\"").Match(text11).Groups[1].Value.Trim();
|
|
if (string.IsNullOrEmpty(value3))
|
|
{
|
|
value3 = "E2";
|
|
}
|
|
postData2 = "checkout.fulfillment.deliveryTab.delivery.shipmentGroups.shipmentGroup-1.shipmentOptionsGroups.shipmentOptionsGroup-1.shippingOptions.selectShippingOption=" + value3 + "&checkout.fulfillment.fulfillmentOptions.selectFulfillmentLocation=HOME";
|
|
HttpResult httpResult4 = postWebContent(redirectURI + "/shop/checkoutx?_a=continueFromFulfillmentToShipping&_m=checkout.fulfillment", postData2, redirectURI + "/shop/checkout?_s=Shipping-init", webHeaderCollection4, "application/json, text/javascript, *; q=0.01", "application/x-www-form-urlencoded");
|
|
if (nationalList != null)
|
|
{
|
|
postData2 = "checkout.shipping.addressContactEmail.address.emailAddress=" + Tools.ToUrlEncode(acount.appleId) + "&checkout.shipping.addressContactPhone.address.fullDaytimePhone=(334)%20334-4334&checkout.shipping.addressNotification.address.emailAddress=&checkout.shipping.addressSelector.selectAddress=newAddr&checkout.shipping.addressSelector.newAddress.saveToAddressBook=true&checkout.shipping.addressSelector.newAddress.address.street2=&checkout.shipping.addressSelector.newAddress.address.lastName=wu&checkout.shipping.addressSelector.newAddress.address.firstName=wang&checkout.shipping.addressSelector.newAddress.address.companyName=&checkout.shipping.addressSelector.newAddress.address.street=109%23&checkout.shipping.addressSelector.newAddress.address.isBusinessAddress=false&checkout.shipping.addressSelector.newAddress.address.zipLookup.postalCode=70068-2260&checkout.shipping.addressSelector.newAddress.address.zipLookup.zipLookupCityState=La%20Place%2C%20LA&checkout.shipping.addressSelector.newAddress.address.zipLookup.countryCode=US";
|
|
string value4 = new Regex("/abs.Address([\\s\\S]*?)}}}},").Match(httpResult4.Html).Groups[1].Value;
|
|
List<string> list = new List<string>();
|
|
string text12 = "checkout.shipping.addressSelector.newAddress.address";
|
|
if (!string.IsNullOrEmpty(value4))
|
|
{
|
|
foreach (Match item in new Regex("\"name\":\"([\\s\\S]*?)\"").Matches(value4))
|
|
{
|
|
string value5 = item.Groups[1].Value;
|
|
if (!string.IsNullOrEmpty(value5))
|
|
{
|
|
list.Add(value5);
|
|
}
|
|
if (list.Count > 15)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
string value6 = new Regex("\"id\":\"([\\s\\S]*?)\"").Match(value4).Groups[1].Value;
|
|
if (!string.IsNullOrEmpty(value6))
|
|
{
|
|
text12 = value6.Replace("-", ".") + ".address";
|
|
}
|
|
}
|
|
if (string.IsNullOrEmpty(nationalList.payment.billingAddress.line2))
|
|
{
|
|
nationalList.payment.billingAddress.line2 = "aabbcc";
|
|
}
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
if (string.IsNullOrEmpty(nationalList.payment.phoneNumber.areaCode))
|
|
{
|
|
stringBuilder.Append("checkout.shipping.addressContactPhone.address.fullDaytimePhone=" + Tools.ToUrlEncode(nationalList.payment.phoneNumber.number));
|
|
}
|
|
else
|
|
{
|
|
stringBuilder.Append("checkout.shipping.addressContactPhone.address.daytimePhoneAreaCode=" + Tools.ToUrlEncode(nationalList.payment.phoneNumber.areaCode));
|
|
stringBuilder.Append("&checkout.shipping.addressContactPhone.address.daytimePhone=" + Tools.ToUrlEncode(nationalList.payment.phoneNumber.number));
|
|
stringBuilder.Append("&checkout.shipping.addressContactPhone.address.isDaytimePhoneSelected=true");
|
|
}
|
|
stringBuilder.Append("&checkout.shipping.addressNotification.address.emailAddress=");
|
|
stringBuilder.Append("&checkout.shipping.addressSelector.selectAddress=newAddr");
|
|
stringBuilder.Append("&checkout.shipping.addressSelector.newAddress.address.street2=" + Tools.ToUrlEncode(nationalList.payment.billingAddress.line2));
|
|
stringBuilder.Append("&checkout.shipping.addressSelector.newAddress.address.lastName=" + Tools.ToUrlEncode(nationalList.payment.ownerName.lastName));
|
|
stringBuilder.Append("&checkout.shipping.addressSelector.newAddress.address.firstName=" + Tools.ToUrlEncode(nationalList.payment.ownerName.firstName));
|
|
stringBuilder.Append("&checkout.shipping.addressSelector.newAddress.address.companyName=");
|
|
stringBuilder.Append("&checkout.shipping.addressSelector.newAddress.address.street=" + Tools.ToUrlEncode(nationalList.payment.billingAddress.line1));
|
|
stringBuilder.Append("&checkout.shipping.addressSelector.newAddress.address.isBusinessAddress=false");
|
|
if (list.Contains("state"))
|
|
{
|
|
stringBuilder.Append("&" + text12 + ".state=" + Tools.ToUrlEncode(nationalList.payment.billingAddress.stateProvinceName));
|
|
}
|
|
if (list.Contains("postalCode"))
|
|
{
|
|
stringBuilder.Append("&" + text12 + ".postalCode=" + Tools.ToUrlEncode(nationalList.payment.billingAddress.postalCode));
|
|
}
|
|
if (list.Contains("city"))
|
|
{
|
|
stringBuilder.Append("&" + text12 + ".city=" + Tools.ToUrlEncode(nationalList.payment.billingAddress.city));
|
|
}
|
|
if (httpResult4.Html.Contains("checkout-shipping-addressSelector-newAddress-cityTypeAhead"))
|
|
{
|
|
stringBuilder.Append("&checkout.shipping.addressSelector.newAddress.address.cityTypeAhead.city=" + Tools.ToUrlEncode(nationalList.payment.billingAddress.stateProvinceName));
|
|
}
|
|
if (httpResult4.Html.Contains("zipLookup"))
|
|
{
|
|
if (Apple_ID_Account_Country == "USA")
|
|
{
|
|
text = "US";
|
|
}
|
|
stringBuilder.Append("&checkout.shipping.addressSelector.newAddress.address.zipLookup.city=" + Tools.ToUrlEncode(nationalList.payment.billingAddress.stateProvinceName));
|
|
stringBuilder.Append("&checkout.shipping.addressSelector.newAddress.address.zipLookup.state=" + Tools.ToUrlEncode(nationalList.payment.billingAddress.stateProvinceName));
|
|
stringBuilder.Append("&checkout.shipping.addressSelector.newAddress.address.zipLookup.postalCode=" + Tools.ToUrlEncode(nationalList.payment.billingAddress.postalCode));
|
|
stringBuilder.Append("&checkout.shipping.addressSelector.newAddress.address.zipLookup.countryCode=" + text.TrimEnd('/').ToUpper());
|
|
}
|
|
string[] array = GetAdditionaFieldsn(Apple_ID_Account_Country).Split('&');
|
|
foreach (string text13 in array)
|
|
{
|
|
if (string.IsNullOrEmpty(text13))
|
|
{
|
|
continue;
|
|
}
|
|
string value7 = "&" + text13;
|
|
bool flag = false;
|
|
string[] array2 = stringBuilder.ToString().Split('&');
|
|
foreach (string text14 in array2)
|
|
{
|
|
if (text14.StartsWith(text13.Split('=')[0]))
|
|
{
|
|
stringBuilder.Replace(text14, text13);
|
|
flag = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!flag)
|
|
{
|
|
stringBuilder.Append(value7);
|
|
}
|
|
}
|
|
postData2 = stringBuilder.ToString();
|
|
}
|
|
HttpResult httpResult5 = postWebContent(redirectURI + "/shop/checkoutx?_a=continueFromShippingToBilling&_m=checkout.shipping", postData2, redirectURI + "/shop/checkout?_s=Shipping-init", webHeaderCollection4, "application/json, text/javascript, *; q=0.01", "application/x-www-form-urlencoded");
|
|
string config = AppSysConfig.getConfig("ContinueWithSelectedAddressKeyWord");
|
|
if (!httpResult5.Html.Contains(config) && !httpResult5.Html.Contains("availableAppleBalance"))
|
|
{
|
|
postData2 = "checkout.shipping.addressContactPhone.address.isDaytimePhoneSelected=true&checkout.shipping.addressNotification.address.emailAddress=&checkout.shipping.addressSelector.selectAddress=address-0";
|
|
string additionaFieldsn = GetAdditionaFieldsn(Apple_ID_Account_Country);
|
|
if (!string.IsNullOrEmpty(additionaFieldsn))
|
|
{
|
|
string[] array = additionaFieldsn.Split('&');
|
|
foreach (string text15 in array)
|
|
{
|
|
postData2 = postData2 + "&" + text15;
|
|
}
|
|
}
|
|
httpResult5 = postWebContent(redirectURI + "/shop/checkoutx?_a=continueFromShippingToBilling&_m=checkout.shipping", postData2, redirectURI + "/shop/checkout?_s=Shipping-init", webHeaderCollection4, "application/json, text/javascript, *; q=0.01", "application/x-www-form-urlencoded");
|
|
}
|
|
postData2 = "";
|
|
string text16 = new Regex(AppSysConfig.getConfig("ContinueWithSelectedAddressRegex")).Match(httpResult5.Html).Groups[1].Value.Trim();
|
|
HttpResult httpResult6 = postWebContent(string.Concat(str1: (!string.IsNullOrEmpty(text16)) ? text16.Replace(text, "") : "/shop/checkoutx?_a=continueWithSelected&_m=checkout.shipping.addressVerification.selectedAddress", str0: redirectURI), postData2, redirectURI + "/shop/checkout?_s=Shipping-init", webHeaderCollection4, "application/json, text/javascript, */*; q=0.01", "application/x-www-form-urlencoded");
|
|
if (httpResult6.StatusCode == HttpStatusCode.OK)
|
|
{
|
|
flag2 = false;
|
|
ShopBillModel shopBillModel = Tools.Todejosn<ShopBillModel>(httpResult6.Html);
|
|
string text17 = shopBillModel?.body?.checkout?.billing?.billingOptions?.selectedBillingOptions?.appleBalance?.appleBalanceInput?.d?.availableAppleBalance;
|
|
if (!string.IsNullOrEmpty(text17))
|
|
{
|
|
Action<string, DisplyType, string> obj2 = action;
|
|
if (obj2 == null)
|
|
{
|
|
if (shopBillModel == null)
|
|
{
|
|
goto IL_1877;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
obj2(base.noticeKey, DisplyType.balance, text17);
|
|
if (shopBillModel == null)
|
|
{
|
|
goto IL_1877;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Action<string, DisplyType, string> obj3 = action;
|
|
if (obj3 == null)
|
|
{
|
|
if (shopBillModel == null)
|
|
{
|
|
goto IL_1877;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
obj3(base.noticeKey, DisplyType.balance, "");
|
|
if (shopBillModel == null)
|
|
{
|
|
goto IL_1877;
|
|
}
|
|
}
|
|
}
|
|
obj4 = shopBillModel.body?.checkout?.billing?.billingOptions?.d?.options;
|
|
goto IL_18bc;
|
|
}
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "余额获取失败");
|
|
if (!agent)
|
|
{
|
|
return AppleQueryStoreBalance(acount, actGetCode, agent: true);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "查询失败#2");
|
|
if (!agent)
|
|
{
|
|
return AppleQueryStoreBalance(acount, actGetCode, agent: true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "商城页面登录失败");
|
|
if (!agent)
|
|
{
|
|
return AppleQueryStoreBalance(acount, actGetCode, agent: true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "页面加载失败");
|
|
if (!agent)
|
|
{
|
|
return AppleQueryStoreBalance(acount, actGetCode, agent: true);
|
|
}
|
|
}
|
|
goto end_IL_00ca;
|
|
IL_1877:
|
|
obj4 = null;
|
|
goto IL_18bc;
|
|
IL_18bc:
|
|
ShopBillModel.Option[] array3 = (ShopBillModel.Option[])obj4;
|
|
if (array3 != null)
|
|
{
|
|
ShopBillModel.Option[] array4 = array3;
|
|
foreach (ShopBillModel.Option option in array4)
|
|
{
|
|
if (!(option.value.ToUpper() == "APPLE_BALANCE".ToUpper()))
|
|
{
|
|
continue;
|
|
}
|
|
if (option.disabled)
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.error, "不可用");
|
|
flag2 = true;
|
|
}
|
|
else if (option.disabledMessage != null)
|
|
{
|
|
bool flag3 = false;
|
|
string[] array = AppSysConfig.getConfig("ShopBanaldisabledMessage").Split(',');
|
|
foreach (string value8 in array)
|
|
{
|
|
if (option.disabledMessage.Contains(value8))
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.error, "不可用");
|
|
flag3 = true;
|
|
flag2 = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!flag3)
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.forbidden, "正常");
|
|
flag2 = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.forbidden, "正常");
|
|
flag2 = true;
|
|
}
|
|
break;
|
|
}
|
|
if (!flag2)
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.reddemUNlock, "未知");
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "没有查询到余额.");
|
|
return true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.reddemUNlock, "未知");
|
|
}
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "查询完成");
|
|
return true;
|
|
end_IL_00ca:;
|
|
}
|
|
catch (Exception ex2)
|
|
{
|
|
APIUtlis.ApiSeriveError(ex2);
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, ex2.Message);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private bool appleauthHashAuth(AppleAcount acount, Func<string, int, string> actGetCode)
|
|
{
|
|
new WebHeaderCollection();
|
|
string url = "https://idmsa.apple.com/appleauth/auth";
|
|
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
|
webHeaderCollection.AddWebHander("X-Apple-Widget-Key", authsigninConfig.Apple_Widget_Key);
|
|
webHeaderCollection.AddWebHander("X-Requested-With", "XMLHttpRequest");
|
|
webHeaderCollection.AddWebHander("X-Apple-Locale", homeLanguage);
|
|
webHeaderCollection.AddWebHander("X-Apple-Auth-Attributes", handelDic.getDicVal("X-Apple-Auth-Attributes", ""));
|
|
webHeaderCollection.AddWebHander("scnt", handelDic.getDicVal("scnt", ""));
|
|
webHeaderCollection.AddWebHander("X-Apple-ID-Session-Id", handelDic.getDicVal("X-Apple-ID-Session-Id", ""));
|
|
addOAuthHanede(webHeaderCollection, authsigninConfig);
|
|
string appleIFDClientInfo = FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent);
|
|
webHeaderCollection.AddWebHander("X-Apple-I-FD-Client-Info", appleIFDClientInfo);
|
|
string text = "";
|
|
lock (lockHas2hObj)
|
|
{
|
|
HttpResult webContent = getWebContent(url, "https://idmsa.apple.com/", webHeaderCollection, "text/html", "application/json");
|
|
if (webContent.StatusCode != HttpStatusCode.OK)
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "双重验证码获取失败");
|
|
return false;
|
|
}
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "等待输入双重验证码.");
|
|
string[] allKeys = webContent.Header.AllKeys;
|
|
foreach (string text2 in allKeys)
|
|
{
|
|
if (text2 == "scnt" || text2 == "X-Apple-Auth-Attributes")
|
|
{
|
|
handelDic.TryAddDic(text2, webContent.Header[text2]);
|
|
}
|
|
}
|
|
string text3 = new Regex("numberWithDialCode\":\"([\\s\\S]*?)\"").Match(webContent.Html).Groups[1].Value.Trim();
|
|
if (actGetCode != null)
|
|
{
|
|
text = actGetCode?.Invoke("请输入账号:" + acount.appleId + ",\n发送至 <" + text3 + "> 的验证码", 1);
|
|
if (text == null || string.IsNullOrEmpty(text))
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "验证码未输入");
|
|
return false;
|
|
}
|
|
if (text.Trim().Length != 6)
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "验证码输入不正确");
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
if (text.Trim().Length == 6)
|
|
{
|
|
return verifyCode(text);
|
|
}
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "验证码输入不正确");
|
|
return false;
|
|
}
|
|
|
|
public bool verifyCode(string code, int retry = 0)
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "正在验证");
|
|
string url = "https://idmsa.apple.com/appleauth/auth/verify/phone/securitycode";
|
|
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
|
webHeaderCollection.AddWebHander("X-Apple-Widget-Key", authsigninConfig.Apple_Widget_Key);
|
|
webHeaderCollection.AddWebHander("X-Requested-With", "XMLHttpRequest");
|
|
webHeaderCollection.AddWebHander("X-Apple-Locale", homeLanguage);
|
|
webHeaderCollection.AddWebHander("X-Apple-Auth-Attributes", handelDic.getDicVal("X-Apple-Auth-Attributes", ""));
|
|
webHeaderCollection.AddWebHander("scnt", handelDic.getDicVal("scnt", ""));
|
|
webHeaderCollection.AddWebHander("X-Apple-ID-Session-Id", handelDic.getDicVal("X-Apple-ID-Session-Id", ""));
|
|
addOAuthHanede(webHeaderCollection, authsigninConfig);
|
|
string appleIFDClientInfo = FDClientInfoHelp.getAppleIFDClientInfo(base.userAgent);
|
|
webHeaderCollection.AddWebHander("X-Apple-I-FD-Client-Info", appleIFDClientInfo);
|
|
string postData = "{\"phoneNumber\":{\"id\":1},\"securityCode\":{\"code\":\"" + code + "\"},\"mode\":\"sms\"}";
|
|
HttpResult httpResult = postWebContent(url, postData, "https://idmsa.apple.com", webHeaderCollection);
|
|
if (httpResult.StatusCode != HttpStatusCode.BadRequest && httpResult.StatusCode != HttpStatusCode.Unauthorized)
|
|
{
|
|
if (httpResult.StatusCode == HttpStatusCode.OK)
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "验证码验证成功");
|
|
return true;
|
|
}
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "验证失败,未知异常");
|
|
return false;
|
|
}
|
|
ServiceErrorsModel serviceErrorsModel = Tools.Todejosn<ServiceErrorsModel>(httpResult.Html);
|
|
if (serviceErrorsModel != null)
|
|
{
|
|
string serviceError = getServiceError(serviceErrorsModel);
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "验证失败:" + serviceError);
|
|
if (serviceError.Contains("发生未知错误") && retry < base.MaxRetryCount)
|
|
{
|
|
Thread.Sleep(3000);
|
|
if (retry != 0)
|
|
{
|
|
base.ProxyIp = "";
|
|
}
|
|
return verifyCode(code, retry + 1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
action?.Invoke(base.noticeKey, DisplyType.xinxi, "验证失败,未知异常");
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public string SelectShippingOptionNullData(string rreustHtml, NationalList payment, string redirectURI, WebHeaderCollection webHeader)
|
|
{
|
|
try
|
|
{
|
|
string text = "";
|
|
string result = "";
|
|
string selectShippingOption = new SelectShippingOptionNullData().getSelectShippingOption();
|
|
foreach (Match item in new Regex("#st([\\s\\S]*?)#end").Matches(selectShippingOption))
|
|
{
|
|
string value = item.Groups[1].Value;
|
|
if (string.IsNullOrEmpty(value))
|
|
{
|
|
continue;
|
|
}
|
|
string value2 = "";
|
|
string text2 = "";
|
|
string text3 = "";
|
|
string text4 = "";
|
|
string text5 = "";
|
|
string text6 = "";
|
|
string[] array = value.Split(';');
|
|
for (int i = 0; i < array.Length; i++)
|
|
{
|
|
string[] array2 = array[i].Split('!');
|
|
if (array2.Length == 2)
|
|
{
|
|
string text7 = array2[1].Trim();
|
|
switch (array2[0].Trim())
|
|
{
|
|
case "r":
|
|
text6 = text7;
|
|
break;
|
|
case "value":
|
|
text5 = text7;
|
|
break;
|
|
case "param":
|
|
text4 = text7;
|
|
break;
|
|
case "post":
|
|
text3 = text7;
|
|
break;
|
|
case "url":
|
|
text2 = text7;
|
|
break;
|
|
case "key":
|
|
value2 = text7;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (string.IsNullOrEmpty(value2) || !rreustHtml.Contains(value2) || payment == null)
|
|
{
|
|
continue;
|
|
}
|
|
text = text3;
|
|
PropertyInfo[] properties = payment.payment.billingAddress.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
|
|
int num = 0;
|
|
string[] array3 = text5.Split(',');
|
|
array = text4.Split(',');
|
|
foreach (string text8 in array)
|
|
{
|
|
string valueItem = array3[num];
|
|
string value3 = "";
|
|
if (valueItem.Contains("p."))
|
|
{
|
|
PropertyInfo propertyInfo = properties.Where((PropertyInfo c) => c.Name == valueItem.Replace("p.", "")).FirstOrDefault();
|
|
if (propertyInfo != null)
|
|
{
|
|
value3 = propertyInfo.GetValue(payment.payment.billingAddress, null) as string;
|
|
}
|
|
}
|
|
if (valueItem.Contains("r.") && int.TryParse(valueItem.Replace("r.", ""), out var result2))
|
|
{
|
|
string[] array4 = text6.Split('|')[result2].Split('-');
|
|
if (array4.Length == 1)
|
|
{
|
|
string value4 = new Regex(array4[0]).Match(rreustHtml).Groups[1].Value;
|
|
if (!string.IsNullOrEmpty(value4))
|
|
{
|
|
value3 = value4;
|
|
}
|
|
}
|
|
if (array4.Length == 2)
|
|
{
|
|
string value5 = new Regex(array4[0]).Match(rreustHtml).Groups[1].Value;
|
|
if (!string.IsNullOrEmpty(value5))
|
|
{
|
|
foreach (Match item2 in new Regex(array4[1]).Matches(value5))
|
|
{
|
|
string value6 = item2.Groups[1].Value;
|
|
if (!string.IsNullOrEmpty(value6))
|
|
{
|
|
value3 = value6;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(value3))
|
|
{
|
|
text = text.Replace("{" + text8 + "}", Tools.ToUrlEncode(value3));
|
|
}
|
|
num++;
|
|
}
|
|
if (!text.Contains("{"))
|
|
{
|
|
result = postWebContent(redirectURI + text2, text, redirectURI + "/shop/checkout?_s=Shipping-init", webHeader, "application/json, text/javascript, */*; q=0.01", "application/x-www-form-urlencoded").Html;
|
|
break;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
APIUtlis.ApiSeriveError(ex);
|
|
Console.WriteLine(ex.Message);
|
|
return rreustHtml;
|
|
}
|
|
}
|
|
|
|
public string GetAdditionaFieldsn(string Account_Country)
|
|
{
|
|
string[] array = new SelectShippingOptionNullData().getSelectShippingAdditionaFieldsn().Split('\n');
|
|
int num = 0;
|
|
string[] array2;
|
|
while (true)
|
|
{
|
|
if (num < array.Length)
|
|
{
|
|
string text = array[num];
|
|
if (!string.IsNullOrEmpty(text))
|
|
{
|
|
array2 = text.Split(':');
|
|
if (array2.Length == 2 && array2[0].Trim() == Account_Country)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
num++;
|
|
continue;
|
|
}
|
|
return "";
|
|
}
|
|
return array2[1].Trim();
|
|
}
|
|
}
|
|
}
|