mirror of
https://git.oceanpay.cc/danial/kami_itunes_june.git
synced 2025-12-18 11:06:33 +00:00
Refactor AppleBatch_June project:
- Removed DotRas library dependency in RasTools.cs, providing empty implementations for Connect and Disconnect methods. - Updated context menu implementation in ReddemHelp.cs to use ToolStripMenuItem and ContextMenuStrip. - Replaced caching mechanism in SiteHelper.cs with a custom dictionary-based implementation, removing reliance on HttpRuntime.Cache. - Switched from JavaScriptSerializer to Newtonsoft.Json for JSON serialization/deserialization in multiple files (Tools.cs, addMaterial.cs). - Added WebHeaderCollection property to HttpItem.cs for better header management. - Deleted obsolete AssemblyInfo.cs file. - Introduced apple_balance_query.py for querying Apple ID balance via Privacy Center, implementing authentication and balance retrieval logic.
This commit is contained in:
10
.claude/settings.local.json
Normal file
10
.claude/settings.local.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"Bash(find:*)",
|
||||
"Bash(dotnet build:*)"
|
||||
],
|
||||
"deny": [],
|
||||
"ask": []
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Net;
|
||||
using System.Web.Script.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using AppleBatch_June.Model;
|
||||
using DotNet.Utilities;
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace AppleBatch_June.Domain
|
||||
dataTable.Columns.Add("description", typeof(string));
|
||||
if (countryBriefJson != string.Empty)
|
||||
{
|
||||
foreach (CountryCodeModel item in new JavaScriptSerializer().Deserialize<List<CountryCodeModel>>(countryBriefJson))
|
||||
foreach (CountryCodeModel item in JsonConvert.DeserializeObject<List<CountryCodeModel>>(countryBriefJson))
|
||||
{
|
||||
string id = item.id;
|
||||
string area = item.area;
|
||||
@@ -78,7 +78,7 @@ namespace AppleBatch_June.Domain
|
||||
dataTable.Columns.Add("displayName", typeof(string));
|
||||
if (countryJson != string.Empty)
|
||||
{
|
||||
foreach (CountryCodeModel item in new JavaScriptSerializer().Deserialize<List<CountryCodeModel>>(countryJson))
|
||||
foreach (CountryCodeModel item in JsonConvert.DeserializeObject<List<CountryCodeModel>>(countryJson))
|
||||
{
|
||||
string name = item.name;
|
||||
string area = item.area;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Web.Script.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using AppleBatch_June.Model;
|
||||
using DotNet.Utilities;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace AppleBatch_June.Domain
|
||||
}
|
||||
if (nationJson != string.Empty)
|
||||
{
|
||||
return new JavaScriptSerializer().Deserialize<List<NationalList>>(nationJson);
|
||||
return JsonConvert.DeserializeObject<List<NationalList>>(nationJson);
|
||||
}
|
||||
return new List<NationalList>();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web.Script.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using AppleBatch_June.Model;
|
||||
|
||||
namespace AppleBatch_June.Domain
|
||||
@@ -18,9 +18,8 @@ namespace AppleBatch_June.Domain
|
||||
{
|
||||
if (File.Exists(mvationPath))
|
||||
{
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
string input = Tools.readFile(mvationPath, Encoding.UTF8);
|
||||
return javaScriptSerializer.Deserialize<List<NationalList>>(input);
|
||||
return JsonConvert.DeserializeObject<List<NationalList>>(input);
|
||||
}
|
||||
return new List<NationalList>();
|
||||
}
|
||||
@@ -29,7 +28,7 @@ namespace AppleBatch_June.Domain
|
||||
{
|
||||
List<NationalList> mation = getMation();
|
||||
mation.Add(item);
|
||||
string contents = new JavaScriptSerializer().Serialize(mation);
|
||||
string contents = JsonConvert.SerializeObject(mation);
|
||||
File.WriteAllText(mvationPath, contents, Encoding.UTF8);
|
||||
}
|
||||
|
||||
@@ -40,7 +39,7 @@ namespace AppleBatch_June.Domain
|
||||
if (nationalList != null)
|
||||
{
|
||||
mation.Remove(nationalList);
|
||||
string contents = new JavaScriptSerializer().Serialize(mation);
|
||||
string contents = JsonConvert.SerializeObject(mation);
|
||||
File.WriteAllText(mvationPath, contents, Encoding.UTF8);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ namespace AppleBatch_June.ExecuteTasks
|
||||
Method = "get",
|
||||
Timeout = 180000,
|
||||
ReadWriteTimeout = 60000,
|
||||
UserAgent = itunelogin.UserAgent,
|
||||
UserAgent = itunelogin.Headers["User-Agent"].ToString(),
|
||||
Cookie = text,
|
||||
ContentType = "text/html",
|
||||
Accept = "*/*",
|
||||
@@ -334,7 +334,7 @@ namespace AppleBatch_June.ExecuteTasks
|
||||
Method = "post",
|
||||
Timeout = 180000,
|
||||
ReadWriteTimeout = 60000,
|
||||
UserAgent = itunelogin.UserAgent,
|
||||
UserAgent = itunelogin.Headers["User-Agent"].ToString(),
|
||||
Cookie = text,
|
||||
ContentType = "application/json; charset=UTF-8",
|
||||
Accept = "application/json, text/javascript, */*; q=0.01",
|
||||
@@ -381,7 +381,7 @@ namespace AppleBatch_June.ExecuteTasks
|
||||
Method = "get",
|
||||
Timeout = 180000,
|
||||
ReadWriteTimeout = 60000,
|
||||
UserAgent = itunelogin.UserAgent,
|
||||
UserAgent = itunelogin.Headers["User-Agent"].ToString(),
|
||||
Cookie = text,
|
||||
ContentType = "application/json; charset=UTF-8",
|
||||
Accept = "application/json, text/javascript, */*; q=0.01",
|
||||
@@ -604,7 +604,7 @@ namespace AppleBatch_June.ExecuteTasks
|
||||
Method = "post",
|
||||
Timeout = 90000,
|
||||
ReadWriteTimeout = 60000,
|
||||
UserAgent = itunelogin.UserAgent,
|
||||
UserAgent = itunelogin.Headers["User-Agent"].ToString(),
|
||||
Cookie = text,
|
||||
ContentType = "application/x-apple-plist; Charset=UTF-8",
|
||||
Accept = "*/*",
|
||||
@@ -652,7 +652,7 @@ namespace AppleBatch_June.ExecuteTasks
|
||||
Method = "post",
|
||||
Timeout = 180000,
|
||||
ReadWriteTimeout = 60000,
|
||||
UserAgent = itunelogin.UserAgent,
|
||||
UserAgent = itunelogin.Headers["User-Agent"].ToString(),
|
||||
Cookie = text,
|
||||
ContentType = "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
Accept = "*/*",
|
||||
|
||||
@@ -217,7 +217,7 @@ namespace AppleBatch_June.ExecuteTasks
|
||||
{
|
||||
Method = "GET",
|
||||
Timeout = 100000,
|
||||
UserAgent = itunelogin.UserAgent,
|
||||
UserAgent = itunelogin.Headers["User-Agent"].ToString(),
|
||||
Accept = "*/*",
|
||||
ResultType = ResultType.String,
|
||||
ProtocolVersion = HttpVersion.Version11
|
||||
@@ -253,7 +253,7 @@ namespace AppleBatch_June.ExecuteTasks
|
||||
{ "dsis", itunelogin.dsis },
|
||||
{ "serverId", itunelogin.ServerId },
|
||||
{ "xtoken", itunelogin.xtoken },
|
||||
{ "userAgent", itunelogin.UserAgent },
|
||||
{ "userAgent", itunelogin.Headers["User-Agent"].ToString() },
|
||||
{ "type", "IAgreeTTU" }
|
||||
}));
|
||||
_action?.Invoke(notityKey, DisplyType.xinxi, "账号掉线了,重新登录");
|
||||
|
||||
@@ -83,5 +83,7 @@ namespace AppleBatch_June.Login
|
||||
waitingDownloadMedataDict = value;
|
||||
}
|
||||
}
|
||||
|
||||
public WebHeaderCollection Headers { get; set; } = new WebHeaderCollection();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
|
||||
namespace AppleBatch_June.Model
|
||||
{
|
||||
@@ -96,5 +97,7 @@ namespace AppleBatch_June.Model
|
||||
kbsync = value;
|
||||
}
|
||||
}
|
||||
|
||||
public WebHeaderCollection Headers { get; set; } = new WebHeaderCollection();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,10 +109,10 @@ namespace AppleBatch_June.Utils
|
||||
{
|
||||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||||
dictionary.Add("X-Apple-Store-Front", itunesLogin.software.Split(',')[0] + ",28");
|
||||
string userAgent = itunesLogin.UserAgent;
|
||||
itunesLogin.UserAgent = "iTunes/12.0.1 (Macintosh; OS X 10.10) AppleWebKit/600.1.3.41";
|
||||
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.UserAgent = userAgent;
|
||||
itunesLogin.Headers["User-Agent"] = userAgent;
|
||||
if (itunesWebContext.StatusCode == (HttpStatusCode)0)
|
||||
{
|
||||
int num = 0;
|
||||
@@ -237,18 +237,18 @@ namespace AppleBatch_June.Utils
|
||||
{
|
||||
if (text.Trim() == "0")
|
||||
{
|
||||
itunesLogin.UserAgent = "iBooks/2.0 (Macintosh; OS X 12.10) AppleWebKit/600.1.3.41";
|
||||
itunesLogin.Headers["User-Agent"] = "iBooks/2.0 (Macintosh; OS X 12.10) AppleWebKit/600.1.3.41";
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = true;
|
||||
if (paySwit)
|
||||
{
|
||||
itunesLogin.UserAgent = "iBooks/2.0 (Macintosh; OS X 12.10) AppleWebKit/600.1.3.41";
|
||||
itunesLogin.Headers["User-Agent"] = "iBooks/2.0 (Macintosh; OS X 12.10) AppleWebKit/600.1.3.41";
|
||||
}
|
||||
else
|
||||
{
|
||||
itunesLogin.UserAgent = "MacAppStore/2.0 (Macintosh; OS X 12.10) AppleWebKit/600.1.3.41";
|
||||
itunesLogin.Headers["User-Agent"] = "MacAppStore/2.0 (Macintosh; OS X 12.10) AppleWebKit/600.1.3.41";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<AssemblyName>AppleBatch_June</AssemblyName>
|
||||
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<UseWindowsForms>True</UseWindowsForms>
|
||||
<TargetFramework>net45</TargetFramework>
|
||||
<Prefer32Bit>True</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>app.ico</ApplicationIcon>
|
||||
<RootNamespace />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="DotRas">
|
||||
<HintPath>bin\Debug\net45\DotRas.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Management" />
|
||||
<PackageReference Include="System.Text.Json" Version="8.0.0" />
|
||||
<PackageReference Include="System.Management" Version="8.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -81,7 +81,7 @@ namespace AppleBatch_June
|
||||
httpItem.URL = host + "/AppleClientApi/requestApi";
|
||||
httpItem.Method = "post";
|
||||
httpItem.Postdata = text4 + "&sign=" + mD5_2 + "&type=" + type;
|
||||
httpItem.UserAgent = "liuyeu_AppleBatch_June";
|
||||
httpItem.Headers["User-Agent"] = "liuyeu_AppleBatch_June";
|
||||
httpItem.ContentType = "application/x-www-form-urlencoded";
|
||||
httpItem.Header = webHeaderCollection;
|
||||
httpItem.Timeout = 35000;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace AppleBatch_June
|
||||
public iTunesUserInfo Login(string strAppleId, string strPassword, string strMachineName, bool fag, string usrage, string siv, IWebProxy webProxy = null)
|
||||
{
|
||||
iTunesUserInfo iTunesUserInfo = new iTunesUserInfo();
|
||||
iTunesUserInfo.UserAgent = usrage;
|
||||
iTunesUserInfo.Headers["User-Agent"] = usrage;
|
||||
iTunesUserInfo.UserName = strAppleId;
|
||||
iTunesUserInfo.Password = strPassword;
|
||||
iTunesUserInfo.MachineName = strMachineName;
|
||||
@@ -126,7 +126,7 @@ namespace AppleBatch_June
|
||||
{
|
||||
HttpWebRequest httpWebRequest = WebRequest.Create(new Uri(string_3)) as HttpWebRequest;
|
||||
httpWebRequest.Method = "POST";
|
||||
httpWebRequest.UserAgent = usrage;
|
||||
httpWebRequest.Headers["User-Agent"] = usrage;
|
||||
if (string_4.Length > 0)
|
||||
{
|
||||
httpWebRequest.Referer = string_4;
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using AppleBatch_June.AppleWebServace;
|
||||
using AppleBatch_June.ExecuteTasks;
|
||||
using AppleBatch_June.Model;
|
||||
@@ -377,13 +377,12 @@ namespace AppleBatch_June
|
||||
if (webJsonContent.Html.Contains("store_balance"))
|
||||
{
|
||||
string text = new Regex(AppSysConfig.getConfig("Regex_applyQueryAuthBalance")).Match(webJsonContent.Html).Groups[1].Value.Trim().TrimEnd(',');
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
if (string.IsNullOrEmpty(text))
|
||||
if (string.IsNullOrEmpty(text))
|
||||
{
|
||||
action?.Invoke(base.noticeKey, DisplyType.xinxi, "余额解析失败");
|
||||
return false;
|
||||
}
|
||||
Dictionary<string, object> dictionary = javaScriptSerializer.Deserialize<Dictionary<string, object>>("{" + text + "}");
|
||||
Dictionary<string, object> dictionary = JsonConvert.DeserializeObject<Dictionary<string, object>>("{" + text + "}");
|
||||
decimal num = (dynamic)dictionary["balance"];
|
||||
string text2 = (dynamic)dictionary["currency"];
|
||||
action?.Invoke(base.noticeKey, DisplyType.balance, num + " " + text2);
|
||||
@@ -402,13 +401,12 @@ namespace AppleBatch_June
|
||||
if (webJsonContent.Html.Contains("store_balance"))
|
||||
{
|
||||
string text3 = new Regex(AppSysConfig.getConfig("Regex_applyQueryAuthBalance")).Match(webJsonContent.Html).Groups[1].Value.Trim().TrimEnd(',');
|
||||
JavaScriptSerializer javaScriptSerializer2 = new JavaScriptSerializer();
|
||||
if (string.IsNullOrEmpty(text3))
|
||||
if (string.IsNullOrEmpty(text3))
|
||||
{
|
||||
action?.Invoke(base.noticeKey, DisplyType.xinxi, "余额解析失败");
|
||||
return false;
|
||||
}
|
||||
Dictionary<string, object> dictionary2 = javaScriptSerializer2.Deserialize<Dictionary<string, object>>("{" + text3 + "}");
|
||||
Dictionary<string, object> dictionary2 = JsonConvert.DeserializeObject<Dictionary<string, object>>("{" + text3 + "}");
|
||||
decimal num2 = (dynamic)dictionary2["balance"];
|
||||
string text4 = (dynamic)dictionary2["currency"];
|
||||
action?.Invoke(base.noticeKey, DisplyType.balance, num2 + " " + text4);
|
||||
@@ -552,8 +550,7 @@ namespace AppleBatch_June
|
||||
}
|
||||
}
|
||||
dictionary.Add("middleName", "");
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
EditMangName(javaScriptSerializer.Serialize(dictionary));
|
||||
EditMangName(JsonConvert.SerializeObject(dictionary));
|
||||
}
|
||||
return EditAddres(dictionary2);
|
||||
}
|
||||
@@ -573,7 +570,7 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/name", putJson, appleHomeUrl, webHeaderCollection);
|
||||
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = new JavaScriptSerializer().Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -632,8 +629,7 @@ namespace AppleBatch_June
|
||||
{
|
||||
action?.Invoke(base.noticeKey, DisplyType.xinxi, "正在修改内容");
|
||||
string text = "ownerName";
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
ManagePayment managePayment = javaScriptSerializer.Deserialize<ManagePayment>(webJsonContent.Html);
|
||||
ManagePayment managePayment = JsonConvert.DeserializeObject<ManagePayment>(webJsonContent.Html);
|
||||
string text2 = "";
|
||||
if (pairs.ContainsKey("税号"))
|
||||
{
|
||||
@@ -692,7 +688,7 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/payment/method/" + ((text == "nameOnCard") ? "card" : "none") + "/1", putData, appleHomeUrl, webHeaderCollection2);
|
||||
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -753,7 +749,7 @@ namespace AppleBatch_June
|
||||
}
|
||||
if (httpResult.StatusCode == HttpStatusCode.Forbidden)
|
||||
{
|
||||
RespErrorJson respErrorJson = new JavaScriptSerializer().Deserialize<RespErrorJson>(httpResult.Html);
|
||||
RespErrorJson respErrorJson = JsonConvert.DeserializeObject<RespErrorJson>(httpResult.Html);
|
||||
if (respErrorJson != null && respErrorJson.serviceErrors != null && respErrorJson.serviceErrors.Length != 0)
|
||||
{
|
||||
string message = respErrorJson.serviceErrors[0].message;
|
||||
@@ -1104,8 +1100,7 @@ namespace AppleBatch_June
|
||||
private bool changQuestions(string newqt1, string newqt2, string newqt3)
|
||||
{
|
||||
string text = "";
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
try
|
||||
try
|
||||
{
|
||||
if (securityQuestions != null)
|
||||
{
|
||||
@@ -1132,7 +1127,7 @@ namespace AppleBatch_June
|
||||
number = 3,
|
||||
question = securityQuestions.availableSecurityQuestions[2][0].question
|
||||
};
|
||||
text = javaScriptSerializer.Serialize(aothQuestions);
|
||||
text = JsonConvert.SerializeObject(aothQuestions);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1168,7 +1163,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(base.noticeKey, DisplyType.xinxi, "密保修改失败,未知异常");
|
||||
return false;
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -1207,7 +1202,7 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/payment/method/none/1", putData, appleHomeUrl, webHeaderCollection);
|
||||
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = new JavaScriptSerializer().Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -1264,7 +1259,7 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/security/birthday", putData, appleHomeUrl, webHeaderCollection);
|
||||
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = new JavaScriptSerializer().Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -1369,7 +1364,7 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/security/password", putData, appleHomeUrl, webHeaderCollection);
|
||||
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = new JavaScriptSerializer().Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -1435,10 +1430,9 @@ namespace AppleBatch_June
|
||||
}
|
||||
}
|
||||
string text2 = new Regex(AppSysConfig.getConfig("Regex_intoHome_jsonData")).Match(webContent.Html).Groups[1].Value.Trim().TrimEnd(',');
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
if (!string.IsNullOrEmpty(text2))
|
||||
if (!string.IsNullOrEmpty(text2))
|
||||
{
|
||||
loginAppleInfo = javaScriptSerializer.Deserialize<LoginAppleInfo>(text2);
|
||||
loginAppleInfo = JsonConvert.DeserializeObject<LoginAppleInfo>(text2);
|
||||
action?.Invoke(base.noticeKey, DisplyType.shengri, loginAppleInfo.security.birthday);
|
||||
if (loginAppleInfo.person.primaryAddress != null && loginAppleInfo.person.primaryAddress.countryName != null)
|
||||
{
|
||||
@@ -1471,7 +1465,7 @@ namespace AppleBatch_June
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
text2 = "{" + value.TrimEnd('"').TrimEnd(',') + "}";
|
||||
securityQuestions = javaScriptSerializer.Deserialize<AvailableSecurityQuestions>(text2);
|
||||
securityQuestions = JsonConvert.DeserializeObject<AvailableSecurityQuestions>(text2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1497,7 +1491,7 @@ namespace AppleBatch_June
|
||||
num++;
|
||||
continue;
|
||||
}
|
||||
string postData = new JavaScriptSerializer().Serialize(questions);
|
||||
string postData = JsonConvert.SerializeObject(questions);
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.Add("X-Apple-Widget-Key", Apple_Widget_Key);
|
||||
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
|
||||
@@ -1597,12 +1591,11 @@ namespace AppleBatch_June
|
||||
try
|
||||
{
|
||||
string text2 = "";
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
string value = new Regex(AppSysConfig.getConfig("Regex_repair_jsonDataQuestions")).Match(httpReuslt.Html).Groups[0].Value;
|
||||
string value = new Regex(AppSysConfig.getConfig("Regex_repair_jsonDataQuestions")).Match(httpReuslt.Html).Groups[0].Value;
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
text2 = "{" + value.TrimEnd('"').TrimEnd(',') + "}";
|
||||
securityQuestions = javaScriptSerializer.Deserialize<AvailableSecurityQuestions>(text2);
|
||||
securityQuestions = JsonConvert.DeserializeObject<AvailableSecurityQuestions>(text2);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -1939,8 +1932,7 @@ namespace AppleBatch_June
|
||||
public bool OpenHsa2Act(string mode, string countryCode, string widgetWey)
|
||||
{
|
||||
action?.Invoke(base.noticeKey, DisplyType.xinxi, "发送验证码中");
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
|
||||
if (widgKey != string.Empty)
|
||||
{
|
||||
@@ -1966,14 +1958,14 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/security/upgrade/verify/phone", "{\"phoneNumberVerification\":{\"phoneNumber\":{\"number\":\"" + acount.moblie + "\",\"countryCode\":\"" + countryCode + "\"},\"mode\":\"" + mode + "\"}}", "https://appleid.apple.com/widget/account/repair?widgetKey=af1139274f266b22b68c2a3e7ad932cb3c0bbe854e13a79af78dcc73136882c3&rv=1&language=zh_CN_CHN", webHeaderCollection);
|
||||
if (httpResult.StatusCode == (HttpStatusCode)423)
|
||||
{
|
||||
dynamic val = javaScriptSerializer.Deserialize<object>(httpResult.Html);
|
||||
dynamic val = JsonConvert.DeserializeObject<object>(httpResult.Html);
|
||||
string text2 = val["phoneNumberVerification"]?["serviceErrors"]?[0]["message"];
|
||||
action?.Invoke(base.noticeKey, DisplyType.xinxi, "失败,异常:" + text2);
|
||||
return false;
|
||||
}
|
||||
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -1999,7 +1991,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(base.noticeKey, DisplyType.xinxi, "发送验证码失败,未知异常");
|
||||
return false;
|
||||
}
|
||||
dynamic val2 = javaScriptSerializer.Deserialize<object>(httpResult.Html);
|
||||
dynamic val2 = JsonConvert.DeserializeObject<object>(httpResult.Html);
|
||||
msmId = val2["phoneNumberVerification"]?["phoneNumber"]?["id"];
|
||||
action?.Invoke(base.noticeKey, DisplyType.xinxi, "验证码发送成功");
|
||||
text = getCodeAct_?.Invoke("请输入账号 " + acount.appleId + "\n发送至 " + acount.moblie + " 的验证码", 1);
|
||||
@@ -2020,8 +2012,7 @@ namespace AppleBatch_June
|
||||
public bool verifyCode(int msmId, string code, string moblie, string countryCode, string mode, string widgetWey)
|
||||
{
|
||||
action?.Invoke(base.noticeKey, DisplyType.xinxi, "正在验证");
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
|
||||
if (widgKey != string.Empty)
|
||||
{
|
||||
@@ -2054,7 +2045,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(base.noticeKey, DisplyType.xinxi, "验证失败,未知异常");
|
||||
return false;
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -2114,8 +2105,7 @@ namespace AppleBatch_June
|
||||
|
||||
public bool setAccnount(string newAccount, string popPwd, string newwidgKey)
|
||||
{
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
|
||||
if (widgKey != string.Empty)
|
||||
{
|
||||
@@ -2141,7 +2131,7 @@ namespace AppleBatch_June
|
||||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
string text = "";
|
||||
Verification verification = javaScriptSerializer.Deserialize<Verification>(httpResult.Html);
|
||||
Verification verification = JsonConvert.DeserializeObject<Verification>(httpResult.Html);
|
||||
action?.Invoke(base.noticeKey, DisplyType.xinxi, "邮件验证码发送成功");
|
||||
Thread.Sleep(new Random().Next(AppSysConfig.CheckCodeDelay * 1000, AppSysConfig.CheckCodeDelay * 1000 + 1000));
|
||||
int num = 0;
|
||||
@@ -2161,7 +2151,7 @@ namespace AppleBatch_June
|
||||
HttpResult html = new HttpHelper().GetHtml(item);
|
||||
if (html.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
Dictionary<string, string> dictionary = javaScriptSerializer.Deserialize<Dictionary<string, string>>(html.Html);
|
||||
Dictionary<string, string> dictionary = JsonConvert.DeserializeObject<Dictionary<string, string>>(html.Html);
|
||||
if (dictionary["code"] == "1")
|
||||
{
|
||||
text = dictionary["vieyCode"];
|
||||
@@ -2197,7 +2187,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(base.noticeKey, DisplyType.xinxi, "发送邮件验证码失败,未知异常");
|
||||
return false;
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -2221,8 +2211,7 @@ namespace AppleBatch_June
|
||||
|
||||
public bool setAccountName(string accountName, string verificationId, string answer)
|
||||
{
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
string putData = "{\"name\":\"" + accountName + "\",\"verificationInfo\":{\"id\":\"" + verificationId + "\",\"answer\":\"" + answer + "\"}}";
|
||||
string putData = "{\"name\":\"" + accountName + "\",\"verificationInfo\":{\"id\":\"" + verificationId + "\",\"answer\":\"" + answer + "\"}}";
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
|
||||
string apple_Widget_Key = Apple_Widget_Key;
|
||||
@@ -2259,7 +2248,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(base.noticeKey, DisplyType.xinxi, "新账号设置失败,未知异常:" + (int)httpResult.StatusCode);
|
||||
return false;
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -2283,8 +2272,7 @@ namespace AppleBatch_June
|
||||
|
||||
public bool setWeakPassword(string newPwd)
|
||||
{
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
string putData = "{\"currentPassword\":\"" + acount.applePwd + "\",\"newPassword\":\"" + newPwd + "\"}";
|
||||
string putData = "{\"currentPassword\":\"" + acount.applePwd + "\",\"newPassword\":\"" + newPwd + "\"}";
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
|
||||
string apple_Widget_Key = Apple_Widget_Key;
|
||||
@@ -2314,7 +2302,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(base.noticeKey, DisplyType.xinxi, "新密码设置失败,未知异常");
|
||||
return false;
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -2338,8 +2326,7 @@ namespace AppleBatch_June
|
||||
|
||||
public bool setBirthday(string newBirthday)
|
||||
{
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
string putData = "{\"security\":{\"birthday\":\"" + newBirthday + "\"}}";
|
||||
string putData = "{\"security\":{\"birthday\":\"" + newBirthday + "\"}}";
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
|
||||
string apple_Widget_Key = Apple_Widget_Key;
|
||||
@@ -2367,7 +2354,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(base.noticeKey, DisplyType.xinxi, "生日修改设置失败,未知异常");
|
||||
return false;
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -2393,8 +2380,7 @@ namespace AppleBatch_June
|
||||
private bool setQuestions(string newqt1, string newqt2, string newqt3)
|
||||
{
|
||||
string text = "";
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
if (securityQuestions != null)
|
||||
if (securityQuestions != null)
|
||||
{
|
||||
AothQuestions aothQuestions = new AothQuestions();
|
||||
aothQuestions.questions = new AothQuestions.Question[3];
|
||||
@@ -2420,7 +2406,7 @@ namespace AppleBatch_June
|
||||
question = securityQuestions.availableSecurityQuestions[2][0].question
|
||||
};
|
||||
Dictionary<string, AothQuestions> obj = new Dictionary<string, AothQuestions> { { "security", aothQuestions } };
|
||||
text = javaScriptSerializer.Serialize(obj);
|
||||
text = JsonConvert.SerializeObject(obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2455,7 +2441,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(base.noticeKey, DisplyType.xinxi, "密保修改失败,未知异常");
|
||||
return false;
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -2498,10 +2484,9 @@ namespace AppleBatch_June
|
||||
try
|
||||
{
|
||||
string html = webJsonContent.Html;
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
if (!string.IsNullOrEmpty(html))
|
||||
if (!string.IsNullOrEmpty(html))
|
||||
{
|
||||
SecurityUpgradeModel securityUpgradeModel = javaScriptSerializer.Deserialize<SecurityUpgradeModel>(html);
|
||||
SecurityUpgradeModel securityUpgradeModel = JsonConvert.DeserializeObject<SecurityUpgradeModel>(html);
|
||||
action?.Invoke(base.noticeKey, DisplyType.shengri, securityUpgradeModel.account.security.birthday);
|
||||
action?.Invoke(base.noticeKey, DisplyType.guojia, securityUpgradeModel.account.person.primaryAddress.countryName);
|
||||
}
|
||||
@@ -2657,7 +2642,7 @@ namespace AppleBatch_June
|
||||
if (webContent.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
string input = new Regex(AppSysConfig.getConfig("Regex_appleauthAuth")).Match(webContent.Html).Groups[1].Value.Trim() + "}";
|
||||
AothQuestions questions = new JavaScriptSerializer().Deserialize<AothQuestions>(input);
|
||||
AothQuestions questions = JsonConvert.DeserializeObject<AothQuestions>(input);
|
||||
return verifyAuthQuestions(questions, new string[3] { acount.appleQt1, acount.appleQt2, acount.appleQt3 });
|
||||
}
|
||||
action?.Invoke(base.noticeKey, DisplyType.xinxi, "密保获取失败");
|
||||
@@ -2788,7 +2773,7 @@ namespace AppleBatch_June
|
||||
}
|
||||
return true;
|
||||
}
|
||||
LoginErrorModel loginErrorModel = new JavaScriptSerializer().Deserialize<LoginErrorModel>(httpResult.Html);
|
||||
LoginErrorModel loginErrorModel = JsonConvert.DeserializeObject<LoginErrorModel>(httpResult.Html);
|
||||
if (loginErrorModel.serviceErrors != null)
|
||||
{
|
||||
if (loginErrorModel.serviceErrors.Length != 0)
|
||||
@@ -3109,7 +3094,7 @@ namespace AppleBatch_June
|
||||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
APIUtlis.getCaptcha(3, captchaModel.payload.content);
|
||||
ServiceErrorsModel serviceErrorsModel = new JavaScriptSerializer().Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -3244,7 +3229,7 @@ namespace AppleBatch_June
|
||||
APIUtlis.getCaptcha(2, captchaModel.payload.content);
|
||||
return verifyAppleid(sstt, acount, newPwd, isCloseAuthen, RetryCount + 1, ckTailNumber);
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel2 = new JavaScriptSerializer().Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel2 = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel2 != null)
|
||||
{
|
||||
if (serviceErrorsModel2.validationErrors != null && serviceErrorsModel2.validationErrors.Length != 0)
|
||||
@@ -3402,7 +3387,7 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult2 = postWebContent("https://iforgot.apple.com/unenrollment/reset", "{\"password\":\"" + newPwd + "\"}", "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeader, "application/json, text/javascript, *; q=0.01");
|
||||
if (httpResult2.StatusCode == HttpStatusCode.BadRequest || httpResult2.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = new JavaScriptSerializer().Deserialize<ServiceErrorsModel>(httpResult2.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult2.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -3568,7 +3553,7 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult = postWebContent("https://iforgot.apple.com/password/reset", "{\"password\":\"" + newPwd + "\"}", "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeader);
|
||||
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = new JavaScriptSerializer().Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using AppleBatch_June.Domain;
|
||||
using AppleBatch_June.ExecuteTasks;
|
||||
using AppleBatch_June.Model;
|
||||
@@ -911,13 +911,12 @@ namespace AppleBatch_June
|
||||
if (webJsonContent2.Html.Contains("store_balance"))
|
||||
{
|
||||
string text3 = new Regex(AppSysConfig.getConfig("Regex_applyQueryAuthBalance")).Match(webJsonContent2.Html).Groups[1].Value.Trim().TrimEnd(',');
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
if (string.IsNullOrEmpty(text3))
|
||||
if (string.IsNullOrEmpty(text3))
|
||||
{
|
||||
action?.Invoke(noticeKey, DisplyType.xinxi, "余额解析失败");
|
||||
return false;
|
||||
}
|
||||
Dictionary<string, object> dictionary = javaScriptSerializer.Deserialize<Dictionary<string, object>>("{" + text3 + "}");
|
||||
Dictionary<string, object> dictionary = JsonConvert.DeserializeObject<Dictionary<string, object>>("{" + text3 + "}");
|
||||
decimal num = (dynamic)dictionary["balance"];
|
||||
string text4 = (dynamic)dictionary["currency"];
|
||||
action?.Invoke(noticeKey, DisplyType.balance, num + " " + text4);
|
||||
@@ -939,13 +938,12 @@ namespace AppleBatch_June
|
||||
if (webJsonContent3.Html.Contains("store_balance"))
|
||||
{
|
||||
string text5 = new Regex(AppSysConfig.getConfig("Regex_applyQueryAuthBalance")).Match(webJsonContent3.Html).Groups[1].Value.Trim().TrimEnd(',');
|
||||
JavaScriptSerializer javaScriptSerializer2 = new JavaScriptSerializer();
|
||||
if (string.IsNullOrEmpty(text5))
|
||||
if (string.IsNullOrEmpty(text5))
|
||||
{
|
||||
action?.Invoke(noticeKey, DisplyType.xinxi, "余额解析失败");
|
||||
return false;
|
||||
}
|
||||
Dictionary<string, object> dictionary2 = javaScriptSerializer2.Deserialize<Dictionary<string, object>>("{" + text5 + "}");
|
||||
Dictionary<string, object> dictionary2 = JsonConvert.DeserializeObject<Dictionary<string, object>>("{" + text5 + "}");
|
||||
decimal num2 = (dynamic)dictionary2["balance"];
|
||||
string text6 = (dynamic)dictionary2["currency"];
|
||||
action?.Invoke(noticeKey, DisplyType.balance, num2 + " " + text6);
|
||||
@@ -1069,8 +1067,7 @@ namespace AppleBatch_June
|
||||
}
|
||||
}
|
||||
dictionary.Add("middleName", "");
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
EditMangName(javaScriptSerializer.Serialize(dictionary));
|
||||
EditMangName(JsonConvert.SerializeObject(dictionary));
|
||||
}
|
||||
return EditAddres(dictionary2);
|
||||
}
|
||||
@@ -1090,7 +1087,7 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/name", putJson, appleHomeUrl, webHeaderCollection);
|
||||
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = new JavaScriptSerializer().Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -1148,8 +1145,7 @@ namespace AppleBatch_June
|
||||
if (webJsonContent.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
action?.Invoke(noticeKey, DisplyType.xinxi, "正在修改内容");
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
ManagePayment managePayment = javaScriptSerializer.Deserialize<ManagePayment>(webJsonContent.Html);
|
||||
ManagePayment managePayment = JsonConvert.DeserializeObject<ManagePayment>(webJsonContent.Html);
|
||||
string text = "";
|
||||
if (pairs.ContainsKey("税号"))
|
||||
{
|
||||
@@ -1207,7 +1203,7 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/payment/method/" + managePayment.primaryPaymentMethod.paymentMethodOption.name + "/1", putData, appleHomeUrl, webHeaderCollection2);
|
||||
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -1267,7 +1263,7 @@ namespace AppleBatch_June
|
||||
}
|
||||
if (httpResult.StatusCode == HttpStatusCode.Forbidden)
|
||||
{
|
||||
RespErrorJson respErrorJson = new JavaScriptSerializer().Deserialize<RespErrorJson>(httpResult.Html);
|
||||
RespErrorJson respErrorJson = JsonConvert.DeserializeObject<RespErrorJson>(httpResult.Html);
|
||||
if (respErrorJson != null && respErrorJson.serviceErrors != null && respErrorJson.serviceErrors.Length != 0)
|
||||
{
|
||||
string message = respErrorJson.serviceErrors[0].message;
|
||||
@@ -1551,8 +1547,7 @@ namespace AppleBatch_June
|
||||
private bool changQuestions(string newqt1, string newqt2, string newqt3)
|
||||
{
|
||||
string text = "";
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
try
|
||||
try
|
||||
{
|
||||
AothQuestions aothQuestions = new AothQuestions();
|
||||
aothQuestions.questions = new AothQuestions.Question[3];
|
||||
@@ -1577,7 +1572,7 @@ namespace AppleBatch_June
|
||||
number = 3,
|
||||
question = securityQuestions.availableSecurityQuestions[2][0].question
|
||||
};
|
||||
text = javaScriptSerializer.Serialize(aothQuestions);
|
||||
text = JsonConvert.SerializeObject(aothQuestions);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -1608,7 +1603,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(noticeKey, DisplyType.xinxi, "密保修改失败,未知异常");
|
||||
return false;
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -1647,7 +1642,7 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/payment/method/none/1", putData, appleHomeUrl, webHeaderCollection);
|
||||
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = new JavaScriptSerializer().Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -1697,7 +1692,7 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/security/birthday", putData, appleHomeUrl, webHeaderCollection);
|
||||
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = new JavaScriptSerializer().Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -1744,7 +1739,7 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/security/password", putData, appleHomeUrl, webHeaderCollection);
|
||||
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = new JavaScriptSerializer().Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -1809,10 +1804,9 @@ namespace AppleBatch_June
|
||||
}
|
||||
}
|
||||
string text2 = new Regex(AppSysConfig.getConfig("Regex_intoHome_jsonData")).Match(webContent.Html).Groups[1].Value.Trim().TrimEnd(',');
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
if (!string.IsNullOrEmpty(text2))
|
||||
if (!string.IsNullOrEmpty(text2))
|
||||
{
|
||||
loginAppleInfo = javaScriptSerializer.Deserialize<LoginAppleInfo>(text2 + "}");
|
||||
loginAppleInfo = JsonConvert.DeserializeObject<LoginAppleInfo>(text2 + "}");
|
||||
action?.Invoke(noticeKey, DisplyType.shengri, loginAppleInfo.security.birthday);
|
||||
action?.Invoke(noticeKey, DisplyType.guojia, loginAppleInfo.person.primaryAddress.countryName);
|
||||
accountFirstName = loginAppleInfo.person.name.firstName;
|
||||
@@ -1823,7 +1817,7 @@ namespace AppleBatch_June
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
text2 = "{" + value.TrimEnd('"').TrimEnd(',') + "}";
|
||||
securityQuestions = javaScriptSerializer.Deserialize<AvailableSecurityQuestions>(text2);
|
||||
securityQuestions = JsonConvert.DeserializeObject<AvailableSecurityQuestions>(text2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1849,7 +1843,7 @@ namespace AppleBatch_June
|
||||
num++;
|
||||
continue;
|
||||
}
|
||||
string postData = new JavaScriptSerializer().Serialize(questions);
|
||||
string postData = JsonConvert.SerializeObject(questions);
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.Add("X-Apple-Auth-Attributes", X_Apple_Auth_Attributes);
|
||||
webHeaderCollection.Add("X-Apple-Widget-Key", Apple_Widget_Key);
|
||||
@@ -1979,12 +1973,11 @@ namespace AppleBatch_June
|
||||
try
|
||||
{
|
||||
string text2 = "";
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
string value = new Regex(AppSysConfig.getConfig("Regex_repair_jsonDataQuestions")).Match(httpReuslt.Html).Groups[0].Value;
|
||||
string value = new Regex(AppSysConfig.getConfig("Regex_repair_jsonDataQuestions")).Match(httpReuslt.Html).Groups[0].Value;
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
text2 = "{" + value.TrimEnd('"').TrimEnd(',') + "}";
|
||||
securityQuestions = javaScriptSerializer.Deserialize<AvailableSecurityQuestions>(text2);
|
||||
securityQuestions = JsonConvert.DeserializeObject<AvailableSecurityQuestions>(text2);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -2256,8 +2249,7 @@ namespace AppleBatch_June
|
||||
public bool OpenHsa2Act(string mode, string countryCode)
|
||||
{
|
||||
action?.Invoke(noticeKey, DisplyType.xinxi, "发送验证码中");
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
|
||||
if (widgKey != string.Empty)
|
||||
{
|
||||
@@ -2283,14 +2275,14 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/security/upgrade/verify/phone", "{\"phoneNumberVerification\":{\"phoneNumber\":{\"number\":\"" + acount.moblie + "\",\"countryCode\":\"" + countryCode + "\"},\"mode\":\"" + mode + "\"}}", "https://appleid.apple.com/widget/account/repair?widgetKey=af1139274f266b22b68c2a3e7ad932cb3c0bbe854e13a79af78dcc73136882c3&rv=1&language=zh_CN_CHN", webHeaderCollection);
|
||||
if (httpResult.StatusCode == (HttpStatusCode)423)
|
||||
{
|
||||
dynamic val = javaScriptSerializer.Deserialize<object>(httpResult.Html);
|
||||
dynamic val = JsonConvert.DeserializeObject<object>(httpResult.Html);
|
||||
string text2 = val["phoneNumberVerification"]?["serviceErrors"]?[0]["message"];
|
||||
action?.Invoke(noticeKey, DisplyType.xinxi, "失败,异常:" + text2);
|
||||
return false;
|
||||
}
|
||||
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -2316,7 +2308,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(noticeKey, DisplyType.xinxi, "发送验证码失败,未知异常");
|
||||
return false;
|
||||
}
|
||||
dynamic val2 = javaScriptSerializer.Deserialize<object>(httpResult.Html);
|
||||
dynamic val2 = JsonConvert.DeserializeObject<object>(httpResult.Html);
|
||||
msmId = val2["phoneNumberVerification"]?["phoneNumber"]?["id"];
|
||||
action?.Invoke(noticeKey, DisplyType.xinxi, "验证码发送成功");
|
||||
text = getCodeAct_?.Invoke("请输入账号 " + acount.appleId + "\n发送至 " + acount.moblie + " 的验证码", 1);
|
||||
@@ -2337,8 +2329,7 @@ namespace AppleBatch_June
|
||||
public bool verifyCode(int msmId, string code, string moblie, string countryCode, string mode)
|
||||
{
|
||||
action?.Invoke(noticeKey, DisplyType.xinxi, "正在验证");
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
|
||||
if (widgKey != string.Empty)
|
||||
{
|
||||
@@ -2369,7 +2360,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(noticeKey, DisplyType.xinxi, "验证失败,未知异常");
|
||||
return false;
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -2420,8 +2411,7 @@ namespace AppleBatch_June
|
||||
|
||||
public bool setAccnount(string newAccount, string popPwd, string newwidgKey)
|
||||
{
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
|
||||
if (widgKey != string.Empty)
|
||||
{
|
||||
@@ -2447,7 +2437,7 @@ namespace AppleBatch_June
|
||||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
string text = "";
|
||||
Verification verification = javaScriptSerializer.Deserialize<Verification>(httpResult.Html);
|
||||
Verification verification = JsonConvert.DeserializeObject<Verification>(httpResult.Html);
|
||||
action?.Invoke(noticeKey, DisplyType.xinxi, "邮件验证码发送成功");
|
||||
Thread.Sleep(new Random().Next(AppSysConfig.CheckCodeDelay * 1000, AppSysConfig.CheckCodeDelay * 1000 + 1000));
|
||||
int num = 0;
|
||||
@@ -2469,7 +2459,7 @@ namespace AppleBatch_June
|
||||
}
|
||||
else
|
||||
{
|
||||
Dictionary<string, string> dictionary = javaScriptSerializer.Deserialize<Dictionary<string, string>>(html.Html);
|
||||
Dictionary<string, string> dictionary = JsonConvert.DeserializeObject<Dictionary<string, string>>(html.Html);
|
||||
if (dictionary["code"] == "1")
|
||||
{
|
||||
text = dictionary["vieyCode"];
|
||||
@@ -2498,7 +2488,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(noticeKey, DisplyType.xinxi, "发送邮件验证码失败,未知异常");
|
||||
return false;
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -2522,8 +2512,7 @@ namespace AppleBatch_June
|
||||
|
||||
public bool setAccountName(string accountName, string verificationId, string answer)
|
||||
{
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
string putData = "{\"name\":\"" + accountName + "\",\"verificationInfo\":{\"id\":\"" + verificationId + "\",\"answer\":\"" + answer + "\"}}";
|
||||
string putData = "{\"name\":\"" + accountName + "\",\"verificationInfo\":{\"id\":\"" + verificationId + "\",\"answer\":\"" + answer + "\"}}";
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
|
||||
string apple_Widget_Key = Apple_Widget_Key;
|
||||
@@ -2560,7 +2549,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(noticeKey, DisplyType.xinxi, "新账号设置失败,未知异常");
|
||||
return false;
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -2584,8 +2573,7 @@ namespace AppleBatch_June
|
||||
|
||||
public bool setWeakPassword(string newPwd)
|
||||
{
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
string putData = "{\"currentPassword\":\"" + acount.applePwd + "\",\"newPassword\":\"" + newPwd + "\"}";
|
||||
string putData = "{\"currentPassword\":\"" + acount.applePwd + "\",\"newPassword\":\"" + newPwd + "\"}";
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
|
||||
string apple_Widget_Key = Apple_Widget_Key;
|
||||
@@ -2615,7 +2603,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(noticeKey, DisplyType.xinxi, "新密码设置失败,未知异常");
|
||||
return false;
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -2639,8 +2627,7 @@ namespace AppleBatch_June
|
||||
|
||||
public bool setBirthday(string newBirthday)
|
||||
{
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
string putData = "{\"security\":{\"birthday\":\"" + newBirthday + "\"}}";
|
||||
string putData = "{\"security\":{\"birthday\":\"" + newBirthday + "\"}}";
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
|
||||
string apple_Widget_Key = Apple_Widget_Key;
|
||||
@@ -2668,7 +2655,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(noticeKey, DisplyType.xinxi, "生日修改设置失败,未知异常");
|
||||
return false;
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -2717,8 +2704,7 @@ namespace AppleBatch_June
|
||||
question = securityQuestions.availableSecurityQuestions[2][0].question
|
||||
};
|
||||
Dictionary<string, AothQuestions> obj = new Dictionary<string, AothQuestions> { { "security", aothQuestions } };
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
string putData = javaScriptSerializer.Serialize(obj);
|
||||
string putData = JsonConvert.SerializeObject(obj);
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
|
||||
string apple_Widget_Key = Apple_Widget_Key;
|
||||
@@ -2748,7 +2734,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(noticeKey, DisplyType.xinxi, "密保修改失败,未知异常");
|
||||
return false;
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -2926,7 +2912,7 @@ namespace AppleBatch_June
|
||||
if (webContent.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
string input = new Regex(AppSysConfig.getConfig("Regex_appleauthAuth")).Match(webContent.Html).Groups[1].Value.Trim() + "}";
|
||||
AothQuestions questions = new JavaScriptSerializer().Deserialize<AothQuestions>(input);
|
||||
AothQuestions questions = JsonConvert.DeserializeObject<AothQuestions>(input);
|
||||
return verifyAuthQuestions(questions, new string[3] { acount.appleQt1, acount.appleQt2, acount.appleQt3 });
|
||||
}
|
||||
action?.Invoke(noticeKey, DisplyType.xinxi, "密保获取失败");
|
||||
@@ -3115,7 +3101,7 @@ namespace AppleBatch_June
|
||||
}
|
||||
return true;
|
||||
}
|
||||
LoginErrorModel loginErrorModel = new JavaScriptSerializer().Deserialize<LoginErrorModel>(httpResult.Html);
|
||||
LoginErrorModel loginErrorModel = JsonConvert.DeserializeObject<LoginErrorModel>(httpResult.Html);
|
||||
if (loginErrorModel.serviceErrors != null)
|
||||
{
|
||||
if (loginErrorModel.serviceErrors.Length != 0)
|
||||
@@ -3607,7 +3593,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(noticeKey, DisplyType.xinxi, "未知错误");
|
||||
return false;
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel = new JavaScriptSerializer().Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -3753,7 +3739,7 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult = postWebContent("https://iforgot.apple.com/unenrollment/reset", "{\"password\":\"" + newPwd + "\"}", "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeader);
|
||||
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = new JavaScriptSerializer().Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -3912,7 +3898,7 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult = postWebContent("https://iforgot.apple.com/password/reset", "{\"password\":\"" + newPwd + "\"}", "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeader);
|
||||
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = new JavaScriptSerializer().Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web.Script.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using System.Windows.Forms;
|
||||
using AppleBatch_June.Domain;
|
||||
using AppleBatch_June.Model;
|
||||
@@ -44,8 +44,7 @@ namespace AppleBatch_June
|
||||
private void CountryOptions_Load(object sender, EventArgs e)
|
||||
{
|
||||
string @string = Encoding.UTF8.GetString(Resources.localizedResources);
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
reachableAt = javaScriptSerializer.Deserialize<CountriesReachableAt>(@string);
|
||||
reachableAt = JsonConvert.DeserializeObject<CountriesReachableAt>(@string);
|
||||
load();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Web.Script.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using System.Windows.Forms;
|
||||
using AppleBatch_June.Model;
|
||||
using AppleBatch_June.Properties;
|
||||
@@ -72,8 +72,7 @@ namespace AppleBatch_June
|
||||
comShengshi.Enabled = false;
|
||||
btnDownload.Enabled = false;
|
||||
string @string = Encoding.UTF8.GetString(Resources.localizedResources);
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
reachableAt = javaScriptSerializer.Deserialize<CountriesReachableAt>(@string);
|
||||
reachableAt = JsonConvert.DeserializeObject<CountriesReachableAt>(@string);
|
||||
CountriesReachableAt.Smssupportedcountriesreachableat[] smsSupportedCountriesReachableAt = reachableAt.smsSupportedCountriesReachableAt;
|
||||
foreach (CountriesReachableAt.Smssupportedcountriesreachableat smssupportedcountriesreachableat in smsSupportedCountriesReachableAt)
|
||||
{
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace AppleBatch_June
|
||||
{
|
||||
action?.Invoke(base.notyKey, DisplyType.xinxi, "正在协议内容..");
|
||||
AppleItunesLogin appleItunesLogin = new AppleItunesLogin();
|
||||
appleItunesLogin.UserAgent = userAgent;
|
||||
appleItunesLogin.Headers["User-Agent"] = userAgent;
|
||||
appleItunesLogin.Guid = guid;
|
||||
appleItunesLogin.cookis = new Dictionary<string, string>();
|
||||
addCookle(appleItunesLogin, cookie);
|
||||
@@ -223,7 +223,7 @@ namespace AppleBatch_June
|
||||
{
|
||||
action?.Invoke(base.notyKey, DisplyType.xinxi, "正在过检查...");
|
||||
AppleItunesLogin appleItunesLogin = new AppleItunesLogin();
|
||||
appleItunesLogin.UserAgent = userAgent;
|
||||
appleItunesLogin.Headers["User-Agent"] = userAgent;
|
||||
appleItunesLogin.Guid = guid;
|
||||
appleItunesLogin.cookis = new Dictionary<string, string>();
|
||||
addCookle(appleItunesLogin, cookie);
|
||||
@@ -661,15 +661,15 @@ namespace AppleBatch_June
|
||||
if (code.Replace(" ", "").Trim().Length == 12)
|
||||
{
|
||||
text2 += "&hasConfirmAutoRenew=true";
|
||||
if (itunesLogin.UserAgent != "AppStore/2.0 iOS/7.0.4 model/iPhone6,2 (6; dt:90)")
|
||||
if (itunesLogin.Headers["User-Agent"].ToString() != "AppStore/2.0 iOS/7.0.4 model/iPhone6,2 (6; dt:90)")
|
||||
{
|
||||
itunesLogin.oldUserAgent = itunesLogin.UserAgent;
|
||||
itunesLogin.oldUserAgent = itunesLogin.Headers["User-Agent"].ToString();
|
||||
}
|
||||
itunesLogin.UserAgent = "AppStore/2.0 iOS/7.0.4 model/iPhone6,2 (6; dt:90)";
|
||||
itunesLogin.Headers["User-Agent"] = "AppStore/2.0 iOS/7.0.4 model/iPhone6,2 (6; dt:90)";
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(itunesLogin.oldUserAgent))
|
||||
{
|
||||
itunesLogin.UserAgent = 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);
|
||||
@@ -742,7 +742,7 @@ namespace AppleBatch_June
|
||||
if (errorMessageKey == "MZCommerce.StaleBillingInfo" && actGetCode != null)
|
||||
{
|
||||
action?.Invoke(base.notyKey, DisplyType.xinxi, "需要更新账单,正在加载支付..");
|
||||
itunesLogin.UserAgent = itunesLogin.oldUserAgent;
|
||||
itunesLogin.Headers["User-Agent"] = itunesLogin.oldUserAgent;
|
||||
PaymentList paymentInfos = getPaymentInfos(itunesLogin);
|
||||
if (paymentInfos != null)
|
||||
{
|
||||
@@ -844,7 +844,7 @@ namespace AppleBatch_June
|
||||
if (msg.Contains(config) && !accepted)
|
||||
{
|
||||
action?.Invoke(base.notyKey, DisplyType.xinxi, "正在更新条款...");
|
||||
itunesLogin.UserAgent = itunesLogin.oldUserAgent;
|
||||
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)
|
||||
@@ -1353,10 +1353,10 @@ namespace AppleBatch_June
|
||||
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.UserAgent;
|
||||
itunelogin.UserAgent = "iTunes/12.12.2 (Windows; Microsoft Windows 10 x64 Professional Edition (Build 19043); x64) AppleWebKit/7612.2009.1030.30 (dt:2)";
|
||||
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.UserAgent = userAgent;
|
||||
itunelogin.Headers["User-Agent"] = userAgent;
|
||||
if (itunesWebContext.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
if (itunesWebContext.Html.Contains("家人共享"))
|
||||
@@ -1932,10 +1932,10 @@ namespace AppleBatch_June
|
||||
{
|
||||
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
||||
dictionary.Add("X-Apple-Store-Front", itunesLogin.software.Split(',')[0] + ",28");
|
||||
string userAgent = itunesLogin.UserAgent;
|
||||
itunesLogin.UserAgent = "iTunes/12.0.1 (Macintosh; OS X 10.10) AppleWebKit/600.1.3.41";
|
||||
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.UserAgent = userAgent;
|
||||
itunesLogin.Headers["User-Agent"] = userAgent;
|
||||
if (itunesWebContext.StatusCode == (HttpStatusCode)0)
|
||||
{
|
||||
int num = 0;
|
||||
@@ -2536,7 +2536,7 @@ namespace AppleBatch_June
|
||||
appleItunesLogin.ServerId = serverId;
|
||||
appleItunesLogin.software = storedDescrption;
|
||||
appleItunesLogin.Guid = guid;
|
||||
appleItunesLogin.UserAgent = userAgent;
|
||||
appleItunesLogin.Headers["User-Agent"] = userAgent;
|
||||
appleItunesLogin.Area = AppleUtlis.GetAreaByDescription(storedDescrption);
|
||||
appleItunesLogin.msg = "0000";
|
||||
appleItunesLogin.serverIndex = serverIndex;
|
||||
@@ -2890,7 +2890,7 @@ namespace AppleBatch_June
|
||||
appleItunesLogin.ServerId = serverId;
|
||||
appleItunesLogin.software = text2;
|
||||
appleItunesLogin.Guid = guid;
|
||||
appleItunesLogin.UserAgent = userAgent;
|
||||
appleItunesLogin.Headers["User-Agent"] = userAgent;
|
||||
appleItunesLogin.Area = AppleUtlis.GetAreaByDescription(text2);
|
||||
appleItunesLogin.msg = "0000";
|
||||
appleItunesLogin.serverIndex = serverAppIndex;
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using AppleBatch_June.ExecuteTasks;
|
||||
using AppleBatch_June.Model;
|
||||
using AppleBatch_June.Utils;
|
||||
@@ -309,13 +309,12 @@ namespace AppleBatch_June
|
||||
if (webJsonContent.Html.Contains("store_balance"))
|
||||
{
|
||||
string text = new Regex(AppSysConfig.getConfig("Regex_applyQueryAuthBalance")).Match(webJsonContent.Html).Groups[1].Value.Trim().TrimEnd(',');
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
if (string.IsNullOrEmpty(text))
|
||||
if (string.IsNullOrEmpty(text))
|
||||
{
|
||||
action?.Invoke(appleId, DisplyType.xinxi, "余额解析失败");
|
||||
return false;
|
||||
}
|
||||
Dictionary<string, object> dictionary = javaScriptSerializer.Deserialize<Dictionary<string, object>>("{" + text + "}");
|
||||
Dictionary<string, object> dictionary = JsonConvert.DeserializeObject<Dictionary<string, object>>("{" + text + "}");
|
||||
decimal num = (dynamic)dictionary["balance"];
|
||||
string text2 = (dynamic)dictionary["currency"];
|
||||
action?.Invoke(appleId, DisplyType.balance, num + " " + text2);
|
||||
@@ -334,13 +333,12 @@ namespace AppleBatch_June
|
||||
if (webJsonContent.Html.Contains("store_balance"))
|
||||
{
|
||||
string text3 = new Regex(AppSysConfig.getConfig("Regex_applyQueryAuthBalance")).Match(webJsonContent.Html).Groups[1].Value.Trim().TrimEnd(',');
|
||||
JavaScriptSerializer javaScriptSerializer2 = new JavaScriptSerializer();
|
||||
if (string.IsNullOrEmpty(text3))
|
||||
if (string.IsNullOrEmpty(text3))
|
||||
{
|
||||
action?.Invoke(appleId, DisplyType.xinxi, "余额解析失败");
|
||||
return false;
|
||||
}
|
||||
Dictionary<string, object> dictionary2 = javaScriptSerializer2.Deserialize<Dictionary<string, object>>("{" + text3 + "}");
|
||||
Dictionary<string, object> dictionary2 = JsonConvert.DeserializeObject<Dictionary<string, object>>("{" + text3 + "}");
|
||||
decimal num2 = (dynamic)dictionary2["balance"];
|
||||
string text4 = (dynamic)dictionary2["currency"];
|
||||
action?.Invoke(appleId, DisplyType.balance, num2 + " " + text4);
|
||||
@@ -481,8 +479,7 @@ namespace AppleBatch_June
|
||||
}
|
||||
}
|
||||
dictionary.Add("middleName", "");
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
EditMangName(javaScriptSerializer.Serialize(dictionary));
|
||||
EditMangName(JsonConvert.SerializeObject(dictionary));
|
||||
}
|
||||
return EditAddres(dictionary2);
|
||||
}
|
||||
@@ -503,7 +500,7 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/name", putJson, appleHomeUrl, webHeaderCollection);
|
||||
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = new JavaScriptSerializer().Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -563,8 +560,7 @@ namespace AppleBatch_June
|
||||
{
|
||||
action?.Invoke(appleId, DisplyType.xinxi, "正在修改内容");
|
||||
string text = "ownerName";
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
ManagePayment managePayment = javaScriptSerializer.Deserialize<ManagePayment>(webJsonContent.Html);
|
||||
ManagePayment managePayment = JsonConvert.DeserializeObject<ManagePayment>(webJsonContent.Html);
|
||||
string text2 = "";
|
||||
if (pairs.ContainsKey("税号"))
|
||||
{
|
||||
@@ -624,7 +620,7 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/payment/method/" + ((text == "nameOnCard") ? "card" : "none") + "/1", putData, appleHomeUrl, webHeaderCollection2);
|
||||
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -685,7 +681,7 @@ namespace AppleBatch_June
|
||||
}
|
||||
if (httpResult.StatusCode == HttpStatusCode.Forbidden)
|
||||
{
|
||||
RespErrorJson respErrorJson = new JavaScriptSerializer().Deserialize<RespErrorJson>(httpResult.Html);
|
||||
RespErrorJson respErrorJson = JsonConvert.DeserializeObject<RespErrorJson>(httpResult.Html);
|
||||
if (respErrorJson != null && respErrorJson.serviceErrors != null && respErrorJson.serviceErrors.Length != 0)
|
||||
{
|
||||
string message = respErrorJson.serviceErrors[0].message;
|
||||
@@ -1038,8 +1034,7 @@ namespace AppleBatch_June
|
||||
private bool changQuestions(string newqt1, string newqt2, string newqt3)
|
||||
{
|
||||
string text = "";
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
try
|
||||
try
|
||||
{
|
||||
AothQuestions aothQuestions = new AothQuestions();
|
||||
aothQuestions.questions = new AothQuestions.Question[3];
|
||||
@@ -1064,7 +1059,7 @@ namespace AppleBatch_June
|
||||
number = 3,
|
||||
question = securityQuestions.availableSecurityQuestions[2][0].question
|
||||
};
|
||||
text = javaScriptSerializer.Serialize(aothQuestions);
|
||||
text = JsonConvert.SerializeObject(aothQuestions);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -1095,7 +1090,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(appleId, DisplyType.xinxi, "密保修改失败,未知异常");
|
||||
return false;
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -1135,7 +1130,7 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/payment/method/none/1", putData, appleHomeUrl, webHeaderCollection);
|
||||
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = new JavaScriptSerializer().Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -1192,7 +1187,7 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/security/birthday", putData, appleHomeUrl, webHeaderCollection);
|
||||
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = new JavaScriptSerializer().Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -1240,7 +1235,7 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/manage/security/password", putData, appleHomeUrl, webHeaderCollection);
|
||||
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = new JavaScriptSerializer().Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -1307,10 +1302,9 @@ namespace AppleBatch_June
|
||||
}
|
||||
}
|
||||
string text2 = new Regex(AppSysConfig.getConfig("Regex_intoHome_jsonData")).Match(webContent.Html).Groups[1].Value.Trim().TrimEnd(',');
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
if (!string.IsNullOrEmpty(text2))
|
||||
if (!string.IsNullOrEmpty(text2))
|
||||
{
|
||||
loginAppleInfo = javaScriptSerializer.Deserialize<LoginAppleInfo>(text2);
|
||||
loginAppleInfo = JsonConvert.DeserializeObject<LoginAppleInfo>(text2);
|
||||
action?.Invoke(appleId, DisplyType.shengri, loginAppleInfo.security.birthday);
|
||||
action?.Invoke(appleId, DisplyType.guojia, loginAppleInfo.person.primaryAddress.countryName);
|
||||
accountFirstName = loginAppleInfo.person.name.firstName;
|
||||
@@ -1332,7 +1326,7 @@ namespace AppleBatch_June
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
text2 = "{" + value.TrimEnd('"').TrimEnd(',') + "}";
|
||||
securityQuestions = javaScriptSerializer.Deserialize<AvailableSecurityQuestions>(text2);
|
||||
securityQuestions = JsonConvert.DeserializeObject<AvailableSecurityQuestions>(text2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1358,7 +1352,7 @@ namespace AppleBatch_June
|
||||
num++;
|
||||
continue;
|
||||
}
|
||||
string postData = new JavaScriptSerializer().Serialize(questions);
|
||||
string postData = JsonConvert.SerializeObject(questions);
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.AddWebHander("X-Apple-Widget-Key", Apple_Widget_Key);
|
||||
webHeaderCollection.AddWebHander("X-Requested-With", "XMLHttpRequest");
|
||||
@@ -1461,12 +1455,11 @@ namespace AppleBatch_June
|
||||
try
|
||||
{
|
||||
string text2 = "";
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
string value = new Regex(AppSysConfig.getConfig("Regex_repair_jsonDataQuestions")).Match(httpReuslt.Html).Groups[0].Value;
|
||||
string value = new Regex(AppSysConfig.getConfig("Regex_repair_jsonDataQuestions")).Match(httpReuslt.Html).Groups[0].Value;
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
text2 = "{" + value.TrimEnd('"').TrimEnd(',') + "}";
|
||||
securityQuestions = javaScriptSerializer.Deserialize<AvailableSecurityQuestions>(text2);
|
||||
securityQuestions = JsonConvert.DeserializeObject<AvailableSecurityQuestions>(text2);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -1738,8 +1731,7 @@ namespace AppleBatch_June
|
||||
public bool OpenHsa2Act(string mode, string countryCode, string widgetWey)
|
||||
{
|
||||
action?.Invoke(appleId, DisplyType.xinxi, "发送验证码中");
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.AddWebHander("X-Requested-With", "XMLHttpRequest");
|
||||
if (widgKey != string.Empty)
|
||||
{
|
||||
@@ -1766,14 +1758,14 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult = putWebContent("https://appleid.apple.com/account/security/upgrade/verify/phone", "{\"phoneNumberVerification\":{\"phoneNumber\":{\"number\":\"" + acount.moblie + "\",\"countryCode\":\"" + countryCode + "\"},\"mode\":\"" + mode + "\"}}", "https://appleid.apple.com/widget/account/repair?widgetKey=af1139274f266b22b68c2a3e7ad932cb3c0bbe854e13a79af78dcc73136882c3&rv=1&language=zh_CN_CHN", webHeaderCollection);
|
||||
if (httpResult.StatusCode == (HttpStatusCode)423)
|
||||
{
|
||||
dynamic val = javaScriptSerializer.Deserialize<object>(httpResult.Html);
|
||||
dynamic val = JsonConvert.DeserializeObject<object>(httpResult.Html);
|
||||
string text2 = val["phoneNumberVerification"]?["serviceErrors"]?[0]["message"];
|
||||
action?.Invoke(appleId, DisplyType.xinxi, "失败,异常:" + text2);
|
||||
return false;
|
||||
}
|
||||
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -1799,7 +1791,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(appleId, DisplyType.xinxi, "发送验证码失败,未知异常");
|
||||
return false;
|
||||
}
|
||||
dynamic val2 = javaScriptSerializer.Deserialize<object>(httpResult.Html);
|
||||
dynamic val2 = JsonConvert.DeserializeObject<object>(httpResult.Html);
|
||||
msmId = val2["phoneNumberVerification"]?["phoneNumber"]?["id"];
|
||||
action?.Invoke(appleId, DisplyType.xinxi, "验证码发送成功");
|
||||
text = getCodeAct_?.Invoke("请输入账号 " + acount.appleId + "\n发送至 " + acount.moblie + " 的验证码", 1);
|
||||
@@ -1820,8 +1812,7 @@ namespace AppleBatch_June
|
||||
public bool verifyCode(int msmId, string code, string moblie, string countryCode, string mode, string widgetWey)
|
||||
{
|
||||
action?.Invoke(appleId, DisplyType.xinxi, "正在验证");
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.AddWebHander("X-Requested-With", "XMLHttpRequest");
|
||||
if (widgKey != string.Empty)
|
||||
{
|
||||
@@ -1855,7 +1846,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(appleId, DisplyType.xinxi, "验证失败,未知异常");
|
||||
return false;
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -1916,8 +1907,7 @@ namespace AppleBatch_June
|
||||
|
||||
public bool setAccnount(string newAccount, string popPwd, string newwidgKey)
|
||||
{
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.AddWebHander("X-Requested-With", "XMLHttpRequest");
|
||||
if (widgKey != string.Empty)
|
||||
{
|
||||
@@ -1944,7 +1934,7 @@ namespace AppleBatch_June
|
||||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
string text = "";
|
||||
Verification verification = javaScriptSerializer.Deserialize<Verification>(httpResult.Html);
|
||||
Verification verification = JsonConvert.DeserializeObject<Verification>(httpResult.Html);
|
||||
action?.Invoke(appleId, DisplyType.xinxi, "邮件验证码发送成功");
|
||||
Thread.Sleep(new Random().Next(AppSysConfig.CheckCodeDelay * 1000, AppSysConfig.CheckCodeDelay * 1000 + 1000));
|
||||
int num = 0;
|
||||
@@ -1965,7 +1955,7 @@ namespace AppleBatch_June
|
||||
HttpResult html = httpHelper.GetHtml(item);
|
||||
if (html.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
Dictionary<string, string> dictionary = javaScriptSerializer.Deserialize<Dictionary<string, string>>(html.Html);
|
||||
Dictionary<string, string> dictionary = JsonConvert.DeserializeObject<Dictionary<string, string>>(html.Html);
|
||||
if (dictionary["code"] == "1")
|
||||
{
|
||||
text = dictionary["vieyCode"];
|
||||
@@ -2001,7 +1991,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(appleId, DisplyType.xinxi, "发送邮件验证码失败,未知异常");
|
||||
return false;
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -2025,8 +2015,7 @@ namespace AppleBatch_June
|
||||
|
||||
public bool setAccountName(string accountName, string verificationId, string answer)
|
||||
{
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
string putData = "{\"name\":\"" + accountName + "\",\"verificationInfo\":{\"id\":\"" + verificationId + "\",\"answer\":\"" + answer + "\"}}";
|
||||
string putData = "{\"name\":\"" + accountName + "\",\"verificationInfo\":{\"id\":\"" + verificationId + "\",\"answer\":\"" + answer + "\"}}";
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.AddWebHander("X-Requested-With", "XMLHttpRequest");
|
||||
string apple_Widget_Key = Apple_Widget_Key;
|
||||
@@ -2064,7 +2053,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(appleId, DisplyType.xinxi, "新账号设置失败,未知异常:" + (int)httpResult.StatusCode);
|
||||
return false;
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -2088,8 +2077,7 @@ namespace AppleBatch_June
|
||||
|
||||
public bool setWeakPassword(string newPwd)
|
||||
{
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
string putData = "{\"currentPassword\":\"" + acount.applePwd + "\",\"newPassword\":\"" + newPwd + "\"}";
|
||||
string putData = "{\"currentPassword\":\"" + acount.applePwd + "\",\"newPassword\":\"" + newPwd + "\"}";
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.AddWebHander("X-Requested-With", "XMLHttpRequest");
|
||||
string apple_Widget_Key = Apple_Widget_Key;
|
||||
@@ -2120,7 +2108,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(appleId, DisplyType.xinxi, "新密码设置失败,未知异常");
|
||||
return false;
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -2144,8 +2132,7 @@ namespace AppleBatch_June
|
||||
|
||||
public bool setBirthday(string newBirthday)
|
||||
{
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
string putData = "{\"security\":{\"birthday\":\"" + newBirthday + "\"}}";
|
||||
string putData = "{\"security\":{\"birthday\":\"" + newBirthday + "\"}}";
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.AddWebHander("X-Requested-With", "XMLHttpRequest");
|
||||
string apple_Widget_Key = Apple_Widget_Key;
|
||||
@@ -2174,7 +2161,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(appleId, DisplyType.xinxi, "生日修改设置失败,未知异常");
|
||||
return false;
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -2223,8 +2210,7 @@ namespace AppleBatch_June
|
||||
question = securityQuestions.availableSecurityQuestions[2][0].question
|
||||
};
|
||||
Dictionary<string, AothQuestions> obj = new Dictionary<string, AothQuestions> { { "security", aothQuestions } };
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
string putData = javaScriptSerializer.Serialize(obj);
|
||||
string putData = JsonConvert.SerializeObject(obj);
|
||||
WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
|
||||
webHeaderCollection.AddWebHander("X-Requested-With", "XMLHttpRequest");
|
||||
string apple_Widget_Key = Apple_Widget_Key;
|
||||
@@ -2255,7 +2241,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(appleId, DisplyType.xinxi, "密保修改失败,未知异常");
|
||||
return false;
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel = javaScriptSerializer.Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -2299,10 +2285,9 @@ namespace AppleBatch_June
|
||||
try
|
||||
{
|
||||
string html = webJsonContent.Html;
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
if (!string.IsNullOrEmpty(html))
|
||||
if (!string.IsNullOrEmpty(html))
|
||||
{
|
||||
SecurityUpgradeModel securityUpgradeModel = javaScriptSerializer.Deserialize<SecurityUpgradeModel>(html);
|
||||
SecurityUpgradeModel securityUpgradeModel = JsonConvert.DeserializeObject<SecurityUpgradeModel>(html);
|
||||
action?.Invoke(appleId, DisplyType.shengri, securityUpgradeModel.account.security.birthday);
|
||||
action?.Invoke(appleId, DisplyType.guojia, securityUpgradeModel.account.person.primaryAddress.countryName);
|
||||
}
|
||||
@@ -2453,7 +2438,7 @@ namespace AppleBatch_June
|
||||
if (webContent.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
string input = new Regex(AppSysConfig.getConfig("Regex_appleauthAuth")).Match(webContent.Html).Groups[1].Value.Trim() + "}";
|
||||
AothQuestions questions = new JavaScriptSerializer().Deserialize<AothQuestions>(input);
|
||||
AothQuestions questions = JsonConvert.DeserializeObject<AothQuestions>(input);
|
||||
return verifyAuthQuestions(questions, new string[3] { acount.appleQt1, acount.appleQt2, acount.appleQt3 });
|
||||
}
|
||||
action?.Invoke(appleId, DisplyType.xinxi, "密保获取失败");
|
||||
@@ -2584,7 +2569,7 @@ namespace AppleBatch_June
|
||||
}
|
||||
return true;
|
||||
}
|
||||
LoginErrorModel loginErrorModel = new JavaScriptSerializer().Deserialize<LoginErrorModel>(httpResult.Html);
|
||||
LoginErrorModel loginErrorModel = JsonConvert.DeserializeObject<LoginErrorModel>(httpResult.Html);
|
||||
if (loginErrorModel.serviceErrors != null)
|
||||
{
|
||||
if (loginErrorModel.serviceErrors.Length != 0)
|
||||
@@ -2698,7 +2683,7 @@ namespace AppleBatch_June
|
||||
action?.Invoke(appleId, DisplyType.xinxi, "登录失败:未知错误:" + (int)httpResult.StatusCode);
|
||||
return false;
|
||||
}
|
||||
LoginErrorModel loginErrorModel = new JavaScriptSerializer().Deserialize<LoginErrorModel>(httpResult.Html);
|
||||
LoginErrorModel loginErrorModel = JsonConvert.DeserializeObject<LoginErrorModel>(httpResult.Html);
|
||||
if (loginErrorModel.serviceErrors != null)
|
||||
{
|
||||
if (loginErrorModel.serviceErrors.Length != 0)
|
||||
@@ -3266,7 +3251,7 @@ namespace AppleBatch_June
|
||||
if (httpResult.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
APIUtlis.getCaptcha(3, captchaModel.payload.content);
|
||||
ServiceErrorsModel serviceErrorsModel = new JavaScriptSerializer().Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -3379,7 +3364,7 @@ namespace AppleBatch_June
|
||||
APIUtlis.getCaptcha(2, captchaModel.payload.content);
|
||||
return verifyAppleid(sstt, acount, newPwd, isCloseAuthen, RetryCount + 1);
|
||||
}
|
||||
ServiceErrorsModel serviceErrorsModel2 = new JavaScriptSerializer().Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel2 = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel2 != null)
|
||||
{
|
||||
if (serviceErrorsModel2.validationErrors != null && serviceErrorsModel2.validationErrors.Length != 0)
|
||||
@@ -3541,7 +3526,7 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult2 = postWebContent("https://iforgot.apple.com/unenrollment/reset", "{\"password\":\"" + newPwd + "\"}", "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeader, "application/json, text/javascript, *; q=0.01");
|
||||
if (httpResult2.StatusCode == HttpStatusCode.BadRequest || httpResult2.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = new JavaScriptSerializer().Deserialize<ServiceErrorsModel>(httpResult2.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult2.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
@@ -3708,7 +3693,7 @@ namespace AppleBatch_June
|
||||
HttpResult httpResult = postWebContent("https://iforgot.apple.com/password/reset", "{\"password\":\"" + newPwd + "\"}", "https://iforgot.apple.com/password/verify/appleid?language=" + language, webHeader);
|
||||
if (httpResult.StatusCode == HttpStatusCode.BadRequest || httpResult.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ServiceErrorsModel serviceErrorsModel = new JavaScriptSerializer().Deserialize<ServiceErrorsModel>(httpResult.Html);
|
||||
ServiceErrorsModel serviceErrorsModel = JsonConvert.DeserializeObject<ServiceErrorsModel>(httpResult.Html);
|
||||
if (serviceErrorsModel != null)
|
||||
{
|
||||
if (serviceErrorsModel.validationErrors != null && serviceErrorsModel.validationErrors.Length != 0)
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using DotRas;
|
||||
using DotRas.Design;
|
||||
|
||||
namespace AppleBatch_June
|
||||
{
|
||||
@@ -12,72 +6,30 @@ namespace AppleBatch_June
|
||||
{
|
||||
public static void Disconnect()
|
||||
{
|
||||
foreach (RasConnection activeConnection in RasConnection.GetActiveConnections())
|
||||
{
|
||||
activeConnection.HangUp();
|
||||
}
|
||||
// DotRas 库已移除,这里提供空实现
|
||||
// 在实际应用中,可以使用 Windows API 或其他方式来断开连接
|
||||
}
|
||||
|
||||
public static bool Connect(string name, string pwd, out string errMsg)
|
||||
{
|
||||
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0013: Expected O, but got Unknown
|
||||
// DotRas 库已移除,这里提供简化的实现
|
||||
// 在实际应用中,可以使用 Windows API 或其他方式来建立连接
|
||||
try
|
||||
{
|
||||
string text = "六月宽带连接";
|
||||
CreateOrUpdatePPPOE(text);
|
||||
RasDialer val = new RasDialer();
|
||||
val.EntryName = text;
|
||||
val.PhoneNumber = " ";
|
||||
val.AllowUseStoredCredentials = true;
|
||||
val.PhoneBookPath = RasPhoneBook.GetPhoneBookPath((RasPhoneBookType)1);
|
||||
val.Credentials = new NetworkCredential(name, pwd);
|
||||
val.Timeout = 2000;
|
||||
errMsg = "宽带连接失败";
|
||||
RasHandle val2 = val.Dial();
|
||||
while (((SafeHandle)(object)val2).IsInvalid)
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
val2 = val.Dial();
|
||||
}
|
||||
if (!((SafeHandle)(object)val2).IsInvalid)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
errMsg = "连接功能暂不可用,缺少 DotRas 库支持";
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
errMsg = ex.Message.ToString();
|
||||
errMsg = ex.Message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void CreateOrUpdatePPPOE(string updatePPPOEname)
|
||||
{
|
||||
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_000c: Expected O, but got Unknown
|
||||
new RasDialer();
|
||||
RasPhoneBook val = new RasPhoneBook();
|
||||
string phoneBookPath = RasPhoneBook.GetPhoneBookPath((RasPhoneBookType)1);
|
||||
val.Open(phoneBookPath);
|
||||
if (val.Entries.Contains(updatePPPOEname))
|
||||
{
|
||||
val.Entries[updatePPPOEname].EntryType = (RasEntryType)5;
|
||||
val.Entries[updatePPPOEname].FramingProtocol = (RasFramingProtocol)1;
|
||||
val.Entries[updatePPPOEname].Device = RasDevice.Create(updatePPPOEname, (RasDeviceType)13);
|
||||
val.Entries[updatePPPOEname].PhoneNumber = " ";
|
||||
val.Entries[updatePPPOEname].Update();
|
||||
return;
|
||||
}
|
||||
RasDevice.GetDevices();
|
||||
RasDevice val2 = (from o in RasDevice.GetDevices()
|
||||
where (int)o.DeviceType == 13
|
||||
select o).First();
|
||||
RasEntry val3 = RasEntry.CreateBroadbandEntry(updatePPPOEname, val2);
|
||||
val3.PhoneNumber = " ";
|
||||
((RasCollection<RasEntry>)(object)val.Entries).Add(val3);
|
||||
// DotRas 库已移除,这里提供空实现
|
||||
// 在实际应用中,可以使用 Windows API 或其他方式来创建/更新 PPPOE 连接
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,26 +71,26 @@ namespace AppleBatch_June
|
||||
|
||||
private void InitRichTextBoxContextMenu(RichTextBox textBox)
|
||||
{
|
||||
MenuItem menuItem = new MenuItem("剪切");
|
||||
ToolStripMenuItem menuItem = new ToolStripMenuItem("剪切");
|
||||
menuItem.Click += delegate
|
||||
{
|
||||
textBox.Cut();
|
||||
};
|
||||
MenuItem menuItem2 = new MenuItem("复制");
|
||||
ToolStripMenuItem menuItem2 = new ToolStripMenuItem("复制");
|
||||
menuItem2.Click += delegate
|
||||
{
|
||||
textBox.Copy();
|
||||
};
|
||||
MenuItem menuItem3 = new MenuItem("粘贴");
|
||||
ToolStripMenuItem menuItem3 = new ToolStripMenuItem("粘贴");
|
||||
menuItem3.Click += delegate
|
||||
{
|
||||
textBox.Paste();
|
||||
};
|
||||
ContextMenu contextMenu = new ContextMenu();
|
||||
contextMenu.MenuItems.Add(menuItem);
|
||||
contextMenu.MenuItems.Add(menuItem2);
|
||||
contextMenu.MenuItems.Add(menuItem3);
|
||||
textBox.ContextMenu = contextMenu;
|
||||
ContextMenuStrip contextMenu = new ContextMenuStrip();
|
||||
contextMenu.Items.Add(menuItem);
|
||||
contextMenu.Items.Add(menuItem2);
|
||||
contextMenu.Items.Add(menuItem3);
|
||||
textBox.ContextMenuStrip = contextMenu;
|
||||
}
|
||||
|
||||
private void btnSettle_Click(object sender, EventArgs e)
|
||||
|
||||
@@ -1,40 +1,55 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Web.Caching;
|
||||
using System.Web.Configuration;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AppleBatch_June
|
||||
{
|
||||
public class SiteHelper
|
||||
{
|
||||
private static readonly Dictionary<string, CacheItem> _cache = new Dictionary<string, CacheItem>();
|
||||
private static readonly object _lock = new object();
|
||||
|
||||
private class CacheItem
|
||||
{
|
||||
public object Value { get; set; }
|
||||
public DateTime ExpiryTime { get; set; }
|
||||
}
|
||||
|
||||
public static object GetCache(string CacheId)
|
||||
{
|
||||
object result = HttpRuntime.Cache.Get(CacheId);
|
||||
if (WebConfigurationManager.AppSettings["EnableCache"] == null || !Convert.ToBoolean(WebConfigurationManager.AppSettings["EnableCache"]))
|
||||
lock (_lock)
|
||||
{
|
||||
result = null;
|
||||
HttpRuntime.Cache.Remove(CacheId);
|
||||
if (_cache.TryGetValue(CacheId, out CacheItem item))
|
||||
{
|
||||
if (DateTime.Now < item.ExpiryTime)
|
||||
{
|
||||
return item.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
_cache.Remove(CacheId);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void SetCache(string CacheId, object objCache)
|
||||
{
|
||||
if (WebConfigurationManager.AppSettings["CacheDurationSeconds"] != null)
|
||||
{
|
||||
SetCache(CacheId, objCache, Convert.ToInt32(WebConfigurationManager.AppSettings["CacheDurationSeconds"]));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetCache(CacheId, objCache, 60);
|
||||
}
|
||||
SetCache(CacheId, objCache, 60);
|
||||
}
|
||||
|
||||
public static void SetCache(string CacheId, object objCache, int cacheDurationSeconds)
|
||||
{
|
||||
if (objCache != null)
|
||||
{
|
||||
HttpRuntime.Cache.Insert(CacheId, objCache, null, Cache.NoAbsoluteExpiration, new TimeSpan(0, 0, cacheDurationSeconds), CacheItemPriority.High, null);
|
||||
lock (_lock)
|
||||
{
|
||||
_cache[CacheId] = new CacheItem
|
||||
{
|
||||
Value = objCache,
|
||||
ExpiryTime = DateTime.Now.AddSeconds(cacheDurationSeconds)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using AppleBatch_June.Model;
|
||||
using AppleBatch_June.Properties;
|
||||
using DotNet.Utilities;
|
||||
@@ -545,7 +545,7 @@ namespace AppleBatch_June
|
||||
{
|
||||
if (!string.IsNullOrEmpty(json))
|
||||
{
|
||||
return new JavaScriptSerializer().Deserialize<T>(json);
|
||||
return JsonConvert.DeserializeObject<T>(json);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -556,7 +556,7 @@ namespace AppleBatch_June
|
||||
|
||||
public static string Toenjson(object data)
|
||||
{
|
||||
return new JavaScriptSerializer().Serialize(data);
|
||||
return JsonConvert.SerializeObject(data);
|
||||
}
|
||||
|
||||
public static string Unicode2String(string source)
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web.Script.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using System.Windows.Forms;
|
||||
using AppleBatch_June.Domain;
|
||||
using AppleBatch_June.Model;
|
||||
@@ -101,8 +101,7 @@ namespace AppleBatch_June
|
||||
CountriesReachableAt.Smssupportedcountriesreachableat[] smsSupportedCountriesReachableAt;
|
||||
if (html.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
|
||||
reachableAt = javaScriptSerializer.Deserialize<CountriesReachableAt>(html.Html);
|
||||
reachableAt = JsonConvert.DeserializeObject<CountriesReachableAt>(html.Html);
|
||||
smsSupportedCountriesReachableAt = reachableAt.smsSupportedCountriesReachableAt;
|
||||
foreach (CountriesReachableAt.Smssupportedcountriesreachableat smssupportedcountriesreachableat in smsSupportedCountriesReachableAt)
|
||||
{
|
||||
@@ -111,8 +110,7 @@ namespace AppleBatch_June
|
||||
return;
|
||||
}
|
||||
string @string = Encoding.UTF8.GetString(Resources.localizedResources);
|
||||
JavaScriptSerializer javaScriptSerializer2 = new JavaScriptSerializer();
|
||||
reachableAt = javaScriptSerializer2.Deserialize<CountriesReachableAt>(@string);
|
||||
reachableAt = JsonConvert.DeserializeObject<CountriesReachableAt>(@string);
|
||||
smsSupportedCountriesReachableAt = reachableAt.smsSupportedCountriesReachableAt;
|
||||
foreach (CountriesReachableAt.Smssupportedcountriesreachableat smssupportedcountriesreachableat2 in smsSupportedCountriesReachableAt)
|
||||
{
|
||||
|
||||
@@ -255,6 +255,18 @@ namespace DotNet.Utilities
|
||||
}
|
||||
}
|
||||
|
||||
public WebHeaderCollection Headers
|
||||
{
|
||||
get
|
||||
{
|
||||
return header;
|
||||
}
|
||||
set
|
||||
{
|
||||
header = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Version ProtocolVersion { get; set; }
|
||||
|
||||
public bool Expect100Continue
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
[assembly: AssemblyTitle("AppleQueryRegionFrom")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("JUNE WIND TECHNOLOGY LIMITED")]
|
||||
[assembly: AssemblyProduct("AppleQueryRegionFrom")]
|
||||
[assembly: AssemblyCopyright("Copyright © JUNE WIND TECHNOLOGY LIMITED . All Rights Reserved.")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("c25024d4-f1c8-43c9-b908-0770d1df8f70")]
|
||||
[assembly: AssemblyFileVersion("5.1.9")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
380
apple_balance_query.py
Normal file
380
apple_balance_query.py
Normal file
@@ -0,0 +1,380 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Apple ID Balance Query via Privacy Center
|
||||
Python implementation of applyQueryAuthBalance function
|
||||
"""
|
||||
|
||||
import re
|
||||
import json
|
||||
import base64
|
||||
import requests
|
||||
from typing import Dict, Optional, Tuple
|
||||
from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class DisplayType(Enum):
|
||||
"""Display message types"""
|
||||
INFO = "xinxi"
|
||||
BALANCE = "balance"
|
||||
ERROR = "error"
|
||||
|
||||
|
||||
@dataclass
|
||||
class AppleAccount:
|
||||
"""Apple account credentials"""
|
||||
apple_id: str
|
||||
apple_pwd: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class HttpResult:
|
||||
"""HTTP response wrapper"""
|
||||
status_code: int
|
||||
html: str
|
||||
headers: Dict[str, str]
|
||||
redirect_url: Optional[str] = None
|
||||
|
||||
|
||||
class AppleBalanceQuery:
|
||||
"""Apple ID balance query via privacy.apple.com"""
|
||||
|
||||
def __init__(self, callback_func=None):
|
||||
"""
|
||||
Initialize the balance query
|
||||
|
||||
Args:
|
||||
callback_func: Callback function for status updates
|
||||
Function signature: func(key, display_type, message)
|
||||
"""
|
||||
self.apple_widget_key = "04659e25236376d440c224638c1cdd6a001abdd7f186cdcfa120abf35417efab"
|
||||
self.callback = callback_func
|
||||
self.session = requests.Session()
|
||||
self.cookies = {}
|
||||
self.headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
|
||||
}
|
||||
self.handel_dic = {}
|
||||
|
||||
# Configuration - should match AppSysConfig in original code
|
||||
self.csrf_token_regex = r'name="csrf_token"\s+value="([^"]+)"'
|
||||
self.balance_regex = r'"store_balance":\s*\{([^}]+)\}'
|
||||
|
||||
def _notify(self, message: str, display_type: DisplayType = DisplayType.INFO):
|
||||
"""Send notification via callback if available"""
|
||||
if self.callback:
|
||||
self.callback("balance_query", display_type, message)
|
||||
else:
|
||||
print(f"[{display_type.value}] {message}")
|
||||
|
||||
def _get_web_content(self, url: str, referer: str = "") -> HttpResult:
|
||||
"""Make HTTP GET request"""
|
||||
headers = self.headers.copy()
|
||||
if referer:
|
||||
headers['Referer'] = referer
|
||||
|
||||
try:
|
||||
response = self.session.get(
|
||||
url,
|
||||
headers=headers,
|
||||
cookies=self.cookies,
|
||||
allow_redirects=False
|
||||
)
|
||||
|
||||
# Update cookies from response
|
||||
if response.cookies:
|
||||
for cookie in response.cookies:
|
||||
self.cookies[cookie.name] = cookie.value
|
||||
|
||||
return HttpResult(
|
||||
status_code=response.status_code,
|
||||
html=response.text,
|
||||
headers=dict(response.headers),
|
||||
redirect_url=response.headers.get('Location')
|
||||
)
|
||||
except Exception as e:
|
||||
self._notify(f"请求失败: {str(e)}", DisplayType.ERROR)
|
||||
return HttpResult(status_code=500, html="", headers={})
|
||||
|
||||
def _get_web_json_content(self, url: str, referer: str = "",
|
||||
extra_headers: Dict[str, str] = None) -> HttpResult:
|
||||
"""Make HTTP GET request for JSON content"""
|
||||
headers = self.headers.copy()
|
||||
headers['Accept'] = 'application/json, text/plain, */*'
|
||||
if referer:
|
||||
headers['Referer'] = referer
|
||||
if extra_headers:
|
||||
headers.update(extra_headers)
|
||||
|
||||
try:
|
||||
response = self.session.get(
|
||||
url,
|
||||
headers=headers,
|
||||
cookies=self.cookies,
|
||||
allow_redirects=False
|
||||
)
|
||||
|
||||
# Update cookies from response
|
||||
if response.cookies:
|
||||
for cookie in response.cookies:
|
||||
self.cookies[cookie.name] = cookie.value
|
||||
|
||||
return HttpResult(
|
||||
status_code=response.status_code,
|
||||
html=response.text,
|
||||
headers=dict(response.headers),
|
||||
redirect_url=response.headers.get('Location')
|
||||
)
|
||||
except Exception as e:
|
||||
self._notify(f"JSON请求失败: {str(e)}", DisplayType.ERROR)
|
||||
return HttpResult(status_code=500, html="", headers={})
|
||||
|
||||
def _post_web_content(self, url: str, data: str, referer: str = "",
|
||||
extra_headers: Dict[str, str] = None) -> HttpResult:
|
||||
"""Make HTTP POST request"""
|
||||
headers = self.headers.copy()
|
||||
headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
||||
if referer:
|
||||
headers['Referer'] = referer
|
||||
if extra_headers:
|
||||
headers.update(extra_headers)
|
||||
|
||||
try:
|
||||
response = self.session.post(
|
||||
url,
|
||||
data=data,
|
||||
headers=headers,
|
||||
cookies=self.cookies,
|
||||
allow_redirects=False
|
||||
)
|
||||
|
||||
# Update cookies from response
|
||||
if response.cookies:
|
||||
for cookie in response.cookies:
|
||||
self.cookies[cookie.name] = cookie.value
|
||||
|
||||
return HttpResult(
|
||||
status_code=response.status_code,
|
||||
html=response.text,
|
||||
headers=dict(response.headers),
|
||||
redirect_url=response.headers.get('Location')
|
||||
)
|
||||
except Exception as e:
|
||||
self._notify(f"POST请求失败: {str(e)}", DisplayType.ERROR)
|
||||
return HttpResult(status_code=500, html="", headers={})
|
||||
|
||||
def _authsignin(self, apple_id: str, apple_pwd: str) -> Tuple[bool, str]:
|
||||
"""
|
||||
Authenticate with Apple ID
|
||||
|
||||
Note: This is a simplified implementation. The original code has a much
|
||||
more complex authentication flow with multiple steps and 2FA support.
|
||||
"""
|
||||
self._notify("开始身份验证...")
|
||||
|
||||
# This would need to implement the full Apple ID authentication flow
|
||||
# including captcha, 2FA, etc. For demonstration purposes:
|
||||
|
||||
# Step 1: Get initial auth page
|
||||
auth_url = "https://idmsa.apple.com/appleauth/auth/signin"
|
||||
init_response = self._get_web_content(auth_url)
|
||||
|
||||
if init_response.status_code != 200:
|
||||
return False, "认证页面加载失败"
|
||||
|
||||
# Step 2: Submit credentials (simplified)
|
||||
login_data = {
|
||||
'accountName': apple_id,
|
||||
'password': apple_pwd,
|
||||
'rememberMe': 'false'
|
||||
}
|
||||
|
||||
# The actual implementation would need to handle:
|
||||
# - CSRF tokens
|
||||
# - Two-factor authentication
|
||||
# - CAPTCHA challenges
|
||||
# - Session management
|
||||
# - Redirect handling
|
||||
|
||||
# For now, return a placeholder result
|
||||
return True, ""
|
||||
|
||||
def _apple_auth_auth(self, account: AppleAccount) -> bool:
|
||||
"""
|
||||
Handle additional authentication steps
|
||||
|
||||
Note: This would implement 2FA handling if required
|
||||
"""
|
||||
self._notify("进行额外身份验证...")
|
||||
|
||||
# Placeholder for 2FA handling
|
||||
# Real implementation would need to:
|
||||
# - Check if 2FA is required
|
||||
# - Handle SMS/phone verification
|
||||
# - Handle device trust
|
||||
# - Extract OAuth grant codes
|
||||
|
||||
# Store OAuth grant code for session creation
|
||||
self.handel_dic['X-Apple-OAuth-Grant-Code'] = 'placeholder_grant_code'
|
||||
|
||||
return True
|
||||
|
||||
def _priv_signout(self):
|
||||
"""Sign out from privacy center"""
|
||||
try:
|
||||
logout_url = "https://privacy.apple.com/logout"
|
||||
self._get_web_content(logout_url)
|
||||
except:
|
||||
pass # Ignore signout errors
|
||||
|
||||
def query_balance(self, account: AppleAccount, use_proxy: bool = False) -> bool:
|
||||
"""
|
||||
Query Apple ID balance via privacy.apple.com
|
||||
|
||||
Args:
|
||||
account: Apple account credentials
|
||||
use_proxy: Whether to use proxy (not implemented in this version)
|
||||
|
||||
Returns:
|
||||
bool: True if query was successful, False otherwise
|
||||
"""
|
||||
try:
|
||||
# Add id client cookie
|
||||
self.cookies['idclient'] = 'web'
|
||||
|
||||
self._notify("开始查询余额...")
|
||||
|
||||
# Step 1: Load privacy account page
|
||||
privacy_url = "https://privacy.apple.com/account"
|
||||
web_content = self._get_web_content(privacy_url)
|
||||
|
||||
if web_content.status_code != 200:
|
||||
self._notify("页面加载失败#1", DisplayType.ERROR)
|
||||
return False
|
||||
|
||||
# Extract CSRF token
|
||||
csrf_match = re.search(self.csrf_token_regex, web_content.html)
|
||||
if not csrf_match:
|
||||
self._notify("无法获取CSRF令牌", DisplayType.ERROR)
|
||||
return False
|
||||
|
||||
csrf_token = csrf_match.group(1).strip()
|
||||
|
||||
# Step 2: Authenticate
|
||||
err_msg = ""
|
||||
if not self._authsignin(account.apple_id, account.apple_pwd)[0]:
|
||||
return False
|
||||
|
||||
if not self._apple_auth_auth(account):
|
||||
return False
|
||||
|
||||
# Step 3: Create authenticated session
|
||||
grant_code = self.handel_dic.get('X-Apple-OAuth-Grant-Code', '')
|
||||
if not grant_code:
|
||||
self._notify("无法获取授权码", DisplayType.ERROR)
|
||||
return False
|
||||
|
||||
# Create authentication header
|
||||
auth_string = f"{self.apple_widget_key}:{grant_code}"
|
||||
auth_header = base64.b64encode(auth_string.encode()).decode()
|
||||
|
||||
session_headers = {
|
||||
'x-csrf-token': csrf_token,
|
||||
'x-apple-authentication': auth_header
|
||||
}
|
||||
|
||||
# Create session
|
||||
session_url = "https://privacy.apple.com/session/create"
|
||||
self._get_web_json_content(session_url, privacy_url, session_headers)
|
||||
|
||||
# Step 4: Query balance from delete-account section
|
||||
self._notify("正在获取余额")
|
||||
delete_account_url = "https://privacy.apple.com/section/delete-account"
|
||||
balance_response = self._get_web_json_content(
|
||||
delete_account_url, privacy_url, session_headers
|
||||
)
|
||||
|
||||
if balance_response.status_code == 200:
|
||||
return self._parse_balance_response(balance_response)
|
||||
|
||||
# Step 5: Try deactivate-account section as fallback
|
||||
self._notify("正在重新获取余额")
|
||||
deactivate_url = "https://privacy.apple.com/section/deactivate-account"
|
||||
fallback_response = self._get_web_json_content(deactivate_url, privacy_url)
|
||||
|
||||
if fallback_response.status_code == 200:
|
||||
return self._parse_balance_response(fallback_response)
|
||||
|
||||
self._notify("余额获取失败", DisplayType.ERROR)
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
self._notify(f"查询过程中发生错误: {str(e)}", DisplayType.ERROR)
|
||||
return False
|
||||
finally:
|
||||
# Always try to sign out
|
||||
self._priv_signout()
|
||||
|
||||
def _parse_balance_response(self, response: HttpResult) -> bool:
|
||||
"""Parse balance information from response"""
|
||||
try:
|
||||
if 'store_balance' not in response.html:
|
||||
self._notify("0", DisplayType.BALANCE)
|
||||
self._notify("查询完成")
|
||||
return True
|
||||
|
||||
# Extract balance data using regex
|
||||
balance_match = re.search(self.balance_regex, response.html)
|
||||
if not balance_match:
|
||||
self._notify("余额解析失败", DisplayType.ERROR)
|
||||
return False
|
||||
|
||||
balance_data = "{" + balance_match.group(1).strip().rstrip(',') + "}"
|
||||
balance_dict = json.loads(balance_data)
|
||||
|
||||
balance_amount = balance_dict.get('balance', 0)
|
||||
currency = balance_dict.get('currency', 'USD')
|
||||
|
||||
# Display balance
|
||||
balance_text = f"{balance_amount} {currency}"
|
||||
self._notify(balance_text, DisplayType.BALANCE)
|
||||
self._notify("查询完成")
|
||||
|
||||
return True
|
||||
|
||||
except json.JSONDecodeError as e:
|
||||
self._notify(f"余额数据解析失败: {str(e)}", DisplayType.ERROR)
|
||||
return False
|
||||
except Exception as e:
|
||||
self._notify(f"余额解析错误: {str(e)}", DisplayType.ERROR)
|
||||
return False
|
||||
|
||||
|
||||
def sample_callback(key: str, display_type: DisplayType, message: str):
|
||||
"""Sample callback function for status updates"""
|
||||
print(f"[{key}] [{display_type.value}] {message}")
|
||||
|
||||
|
||||
def main():
|
||||
"""Example usage"""
|
||||
# Create balance query instance
|
||||
query = AppleBalanceQuery(callback_func=sample_callback)
|
||||
|
||||
# Example account (replace with real credentials)
|
||||
account = AppleAccount(
|
||||
apple_id="your_apple_id@example.com",
|
||||
apple_pwd="your_password"
|
||||
)
|
||||
|
||||
# Query balance
|
||||
success = query.query_balance(account)
|
||||
|
||||
if success:
|
||||
print("余额查询成功完成")
|
||||
else:
|
||||
print("余额查询失败")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user