初始提交
This commit is contained in:
597
Services/Hncore.Pass.Vpn/Service/AgentClient6Service.cs
Normal file
597
Services/Hncore.Pass.Vpn/Service/AgentClient6Service.cs
Normal file
@@ -0,0 +1,597 @@
|
||||
using AngleSharp.Dom;
|
||||
using AngleSharp.Html.Parser;
|
||||
using Bogus.DataSets;
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.Serializer;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Vpn.Model;
|
||||
using Hncore.Pass.Vpn.Request.Product;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
namespace Hncore.Pass.Vpn.Service
|
||||
{
|
||||
public class AgentClient6Service : AgentClientBaseService
|
||||
{
|
||||
string secretId = "20200716182518182489";
|
||||
string secretKey = "OFcEJAfzYjWT3e2s";
|
||||
string UserApiUrl = "userapi/";
|
||||
string LoginIndexUrl { get; set; } = "login/";
|
||||
string LoginUrl { get; set; } = "loginauth/";
|
||||
string LoginCodeUrl { get; set; } = "";
|
||||
string RefrushTokenUrl { get; set; } = "userInfo/";
|
||||
string SingleAddUrl { get; set; } = "userapi/";
|
||||
string SingleReAddUrl { get; set; } = "user_buy_server";
|
||||
string MuiltAddUrl { get; set; } = "agent/memberMuiltAdd.html";
|
||||
string RefundUrl { get; set; } = "agent/memberRefundAct.html ";
|
||||
string UpdateUrl = "setuser";
|
||||
string OnlineUrl { get; set; } = "active_log/?user=";
|
||||
string KIllUrl { get; set; } = "agent/disConnect2/radacctid/{0}.html";
|
||||
string searchAccountUrl = "userList/?sum=100&page=1&search_data=";
|
||||
string searchTestAccountUrl = "agent/memberList/type/0.html?search=1&username=";
|
||||
string DeleteUrl { get; set; } = "agent/memberDel/id/";//1160862.html";
|
||||
IHttpClientFactory m_HttpClientFactory;
|
||||
public AgentClient6Service(IHttpClientFactory httpClientFactory):base(httpClientFactory)
|
||||
{
|
||||
m_HttpClientFactory = httpClientFactory;
|
||||
}
|
||||
|
||||
protected override HttpClient CreateHttpClient(bool autoCooke = true)
|
||||
{
|
||||
var client = m_HttpClientFactory.CreateClient("agentClient1.0");
|
||||
client.BaseAddress = new System.Uri(this.BaseUrl);
|
||||
if (this.Token.Has() && autoCooke)
|
||||
{
|
||||
AddCookie(client, this.Token);
|
||||
}
|
||||
return client;
|
||||
}
|
||||
|
||||
private string FormatRequest(Dictionary<string, string> map)
|
||||
{
|
||||
map["secretId"] = this.secretId;
|
||||
map["secretKey"] = this.secretKey;
|
||||
var data = string.Join("&", map.Select(m => $"{m.Key}={m.Value}"));
|
||||
return data;
|
||||
}
|
||||
|
||||
public override async Task<int> RefrushStatus()
|
||||
{
|
||||
int status = 0;
|
||||
if (this.Token.Has())
|
||||
{
|
||||
var client = CreateHttpClient();
|
||||
if (this.RefrushTokenUrl.Has())
|
||||
{
|
||||
// client.DefaultRequestHeaders.Add("Cookie", this.Token);
|
||||
var getResp = await client.GetAsync(this.RefrushTokenUrl);
|
||||
if (getResp.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
status = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
var request = new AgentLoginRequest()
|
||||
{
|
||||
Account = this.Product.Account,
|
||||
Pwd = this.Product.Pwd
|
||||
};
|
||||
|
||||
var ret = await this.Login(request);
|
||||
if (ret.Code == ResultCode.C_SUCCESS)
|
||||
{
|
||||
this.Product.Token = ret.Data.ToString();
|
||||
status = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine("离线");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
public override async Task<(byte[], string)> GetCode()
|
||||
{
|
||||
|
||||
return (null, "");
|
||||
}
|
||||
|
||||
private async Task<(string, string)> GetHomeCookie()
|
||||
{
|
||||
var client = CreateHttpClient(false);
|
||||
var getResp = await client.GetAsync(this.LoginIndexUrl);
|
||||
var cookies = this.GetCookies(getResp);
|
||||
cookies = cookies.Replace("path=/;", "").Replace("httponly", "").Trim();
|
||||
|
||||
var content = await getResp.Content.ReadAsStringAsync();
|
||||
|
||||
var parser = new HtmlParser();
|
||||
var document = await parser.ParseDocumentAsync(content);
|
||||
var csrf_tokenNode = document.QuerySelector("input[name=csrfmiddlewaretoken]");//<input type='hidden' name='csrfmiddlewaretoken' value='b8XKenjQ9GJUJF0xSZySXLsG5FGNHepk' />
|
||||
|
||||
var csrf_token = csrf_tokenNode.GetAttribute("value");
|
||||
return (cookies, csrf_token);
|
||||
}
|
||||
|
||||
public override async Task<ApiResult> Login(AgentLoginRequest request)
|
||||
{
|
||||
var tokens = await this.GetHomeCookie();
|
||||
var client = CreateHttpClient(false);
|
||||
client.DefaultRequestHeaders.Add("Connection", "keep-alive");
|
||||
client.DefaultRequestHeaders.Add("Upgrade-Insecure-Requests", "1");
|
||||
|
||||
var csrftoken = this.GetCookieValue(tokens.Item1, "csrftoken");
|
||||
var key = this.GetCookieValue(tokens.Item1, "key");
|
||||
var map = new Dictionary<string, string>(){
|
||||
{"csrfmiddlewaretoken",tokens.Item2},
|
||||
{"username",request.Account },
|
||||
{"password",request.Pwd },
|
||||
{"remember",key },
|
||||
};
|
||||
LogHelper.Info("Login", map.ToJson());
|
||||
|
||||
var loginToken = $"csrftoken={csrftoken};key={key}";
|
||||
AddCookie(client, loginToken);
|
||||
var resp = await client.PostAsForm(this.LoginUrl, map);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
if (resp.StatusCode != HttpStatusCode.Found || resp.Headers.Location.ToString().IndexOf("http://user.webok.me/userInfo/")==-1)
|
||||
{
|
||||
return new ApiResult(ResultCode.C_VISITOR_CHECKING, "登录失败");
|
||||
}
|
||||
var sessionid = this.GetCookie(resp, "sessionid");
|
||||
var username_user = this.GetCookie(resp, "username_user");
|
||||
request.Key = $"{loginToken};{sessionid};{username_user}";
|
||||
return new ApiResult(request.Key);
|
||||
}
|
||||
public override bool CheckAccount(int productId,List<string> accounts)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新开
|
||||
/// </summary>
|
||||
/// <param name="packageId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<ApiResult> NewAccount(string packageKey, string account, string pwd, int connCount = 1, int accountType = 1, int payCount = 1)
|
||||
{
|
||||
if (packageKey == "test_pay")
|
||||
return await NewTestAccount(account, pwd);
|
||||
var client = CreateHttpClient();
|
||||
var map = new Dictionary<string, string>(){
|
||||
{"type","adduser" },
|
||||
{"user",account },
|
||||
{"pass",pwd },
|
||||
{"logincount",connCount.ToString()},
|
||||
{"serverid",packageKey },
|
||||
};
|
||||
var title = GetOpTitle("NewAccount", account);
|
||||
LogHelper.Info(title, map.ToJson());
|
||||
try
|
||||
{
|
||||
var resp = await client.GetAsync(this.UserApiUrl + "?" + this.FormatRequest(map));
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["code"].ToString();
|
||||
if (status == "1")
|
||||
{
|
||||
return new ApiResult(ResultCode.C_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.Error(title, content);
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "开户失败");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error(title, ex.GetInfo());
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "开户失败");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 新开测试账号
|
||||
/// </summary>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ApiResult> NewTestAccount(string account, string pwd)
|
||||
{
|
||||
var client = CreateHttpClient();
|
||||
var map = new Dictionary<string, string>(){
|
||||
{"user",account},
|
||||
{"pass",pwd },
|
||||
{"type","newuser" },
|
||||
{"logincount","1"},
|
||||
{"serverid","test_pay" },
|
||||
{"username",this.Product.Account },
|
||||
{"otherserver","no" },
|
||||
};
|
||||
var title = GetOpTitle("NewTestAccount", account);
|
||||
LogHelper.Info(title, map.ToJson());
|
||||
try
|
||||
{
|
||||
var resp = await client.PostAsForm("userRegisterAdd/" , map);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["code"].ToString();
|
||||
if (status == "1")
|
||||
{
|
||||
return new ApiResult(ResultCode.C_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.Error(title, content);
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "开户失败");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error(title, ex.Message);
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "开户失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 新开
|
||||
/// </summary>
|
||||
/// <param name="packageId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<ApiResult> NewMuiltAccount(string packageKey, string account, string pwd, int connCount = 1, int accountType = 1,int startNum=0, int endNum=1 )
|
||||
{
|
||||
var client = CreateHttpClient();
|
||||
var map = new Dictionary<string, string>(){
|
||||
{"taocanName",packageKey },
|
||||
{"usernameTpl",account },
|
||||
{"password",pwd },
|
||||
{"maxonline",connCount.ToString()},
|
||||
{"startNum",startNum.ToString()},
|
||||
{"endNum",endNum.ToString()},
|
||||
{"mode",accountType.ToString()},
|
||||
};
|
||||
var title = GetOpTitle("NewMuiltAccount", account);
|
||||
LogHelper.Info(title, map.ToJson());
|
||||
try
|
||||
{
|
||||
var resp = await client.PostAsForm(this.MuiltAddUrl, map);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
if (content.Has() && content.IndexOf("<td>成功</td>") != -1)
|
||||
{
|
||||
return new ApiResult(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.Error(title, content);
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "开户失败");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error(title, ex.Message);
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "开户失败");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 续费
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<ApiResult> NewReAccount(string packageKey, string account, int connCount)
|
||||
{
|
||||
var ret = await this.GetAccountInfo(account);
|
||||
if (ret.Code != ResultCode.C_SUCCESS|| ret.Data==null)
|
||||
{
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "账户不存在,续费失败");
|
||||
}
|
||||
var client = CreateHttpClient();
|
||||
var map = new Dictionary<string, string>(){
|
||||
{"user",account },
|
||||
{"serverid",packageKey },
|
||||
{"type","buy" },
|
||||
};
|
||||
var title = GetOpTitle("NewReAccount", account);
|
||||
LogHelper.Info(title, map.ToJson());
|
||||
try
|
||||
{
|
||||
var resp = await client.GetAsync(this.UserApiUrl + "?" + this.FormatRequest(map));
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["code"].ToString();
|
||||
if (status == "1")
|
||||
{
|
||||
return new ApiResult(ResultCode.C_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.Error(title, content);
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "续费失败");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error(title, ex.Message);
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "续费失败");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除账号
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<bool> DeleteAccount(string account)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// 得到账号信息
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<ApiResult<OriginAccountModel>> GetAccountInfo(string account, bool isTest = false)
|
||||
{
|
||||
var client = CreateHttpClient();
|
||||
var map = new Dictionary<string, string>(){
|
||||
{"user",account },
|
||||
{"type","getuserinfo" },
|
||||
};
|
||||
var title = GetOpTitle("GetAccountInfo", account);
|
||||
try
|
||||
{
|
||||
var searchUser = $"userList/?sum=100&page=1&search_data={account}";
|
||||
var resp = await client.GetAsync(searchUser);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
|
||||
var parser = new HtmlParser();
|
||||
var document = await parser.ParseDocumentAsync(content);
|
||||
////table class="table table-bordered"
|
||||
var trs = document.QuerySelectorAll("#datatable tr").ToList();
|
||||
// var trs= table.QuerySelectorAll("tr").ToList();
|
||||
var retData = new List<OriginAccountModel>();
|
||||
var info = "";
|
||||
if (trs.Count() > 1)
|
||||
{
|
||||
//var tr = trs.Skip(1).FirstOrDefault();
|
||||
foreach (var tr in trs.Skip(1))
|
||||
{
|
||||
var tds = tr.QuerySelectorAll("td").ToList();
|
||||
var tdAccount = tds[1].TextContent;
|
||||
if (tdAccount != account)
|
||||
continue;
|
||||
info = string.Join("", tds.Select(m => m.OuterHtml));
|
||||
var trData = new OriginAccountModel
|
||||
{
|
||||
Account = account,
|
||||
Pwd = tds[2].TextContent,
|
||||
AccountType = tds[3].TextContent,
|
||||
Package = tds[3].TextContent,
|
||||
RegistTime = tds[5].TextContent,
|
||||
EndTime = tds[6].TextContent,
|
||||
ConnectCount = tds[4].TextContent,
|
||||
IsActive = tds[7].TextContent,
|
||||
Remark = tds[8].TextContent,
|
||||
};
|
||||
|
||||
trData.RealEndTime = DateTime.Parse(trData.EndTime);
|
||||
if (trData.RealEndTime < DateTime.Now)
|
||||
{
|
||||
trData.RestTime = "已过期";
|
||||
}
|
||||
else
|
||||
{
|
||||
trData.RestTime = (trData.RealEndTime - DateTime.Now).ToString(@"dd\.hh\:mm\:ss");
|
||||
}
|
||||
|
||||
var button = tr.LastElementChild.QuerySelector("button")?.Attributes["onclick"]?.Value;
|
||||
if (button.Has())
|
||||
{
|
||||
var start = button.IndexOf('(');
|
||||
var end = button.IndexOf(")");
|
||||
if (start != -1 && end != -1)
|
||||
{
|
||||
trData.Id = button.Substring(start + 1, end - start);
|
||||
}
|
||||
}
|
||||
return new ApiResult<OriginAccountModel>(trData);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error(title, ex.Message);
|
||||
}
|
||||
return new ApiResult<OriginAccountModel>(ResultCode.C_INVALID_ERROR, "没有查询到信息");
|
||||
}
|
||||
/// <summary>
|
||||
/// 修改账号密码
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<bool> UpdateAccountPwd(string account, string pwd)
|
||||
{
|
||||
var client = CreateHttpClient();
|
||||
var map = new Dictionary<string, string>(){
|
||||
{"user",account },
|
||||
{"new_pwd",pwd },
|
||||
{"type","setuser" },
|
||||
};
|
||||
var title = GetOpTitle("UpdateAccountPwd", account);
|
||||
LogHelper.Info(title, map.ToJson());
|
||||
try
|
||||
{
|
||||
var resp = await client.GetAsync(this.UserApiUrl + "?" + this.FormatRequest(map));
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["code"].ToString();
|
||||
if (status == "1")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.Error(title, content);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error(GetOpTitle("UpdateAccountPwd", account), ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// 退款
|
||||
/// </summary>
|
||||
/// <param name="packageId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<ApiResult> Refund(string account, string packageKey, int days)
|
||||
{
|
||||
var title = GetOpTitle("Refund", account);
|
||||
LogHelper.Info(title, account);
|
||||
return new ApiResult(ResultCode.C_INVALID_ERROR, "退款失败-不支持退款");
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否在线
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<ApiResult<List<OriginAccountOnlineModel>>> OnLine(string account)
|
||||
{
|
||||
|
||||
var client = CreateHttpClient();
|
||||
var title = GetOpTitle("OnLine", account);
|
||||
|
||||
var info = "";
|
||||
try
|
||||
{
|
||||
var url = this.OnlineUrl + account;
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
|
||||
var parser = new HtmlParser();
|
||||
var document = await parser.ParseDocumentAsync(content);
|
||||
var trs = document.QuerySelectorAll("table.table tr").ToList();
|
||||
var retData = new List<OriginAccountOnlineModel>();
|
||||
if (trs.Count() > 1)
|
||||
{
|
||||
foreach (var tr in trs.Skip(1))
|
||||
{
|
||||
var tds = tr.QuerySelectorAll("td").ToList();
|
||||
var tdAccount = tds[1].FirstChild.TextContent;
|
||||
if (tdAccount != account)
|
||||
continue;
|
||||
info = string.Join("", tds.Select(m => m.OuterHtml));
|
||||
//序号 会员账号 服务器IP 登录时间 在线时长 会员IP 上行流量 下行流量 操作
|
||||
|
||||
var trData = new OriginAccountOnlineModel
|
||||
{
|
||||
Account = account,
|
||||
ServerIP = tds[6].TextContent,
|
||||
LoginTime = tds[1].TextContent,
|
||||
OnlineTime = tds[3].TextContent,
|
||||
LoginIP = tds[5].TextContent,
|
||||
UpStream = tds[4].TextContent,
|
||||
DownStream = tds[4].TextContent,
|
||||
Id= account,
|
||||
};
|
||||
var href = tr.LastElementChild.QuerySelector("a")?.Attributes["href"]?.Value;
|
||||
if (href.Has())
|
||||
{
|
||||
var start = href.LastIndexOf('/');
|
||||
var end = href.IndexOf(".html");
|
||||
if (start != -1 && end != -1)
|
||||
{
|
||||
trData.Id = href.Substring(start + 1, end - start).TrimEnd('.');
|
||||
}
|
||||
}
|
||||
retData.Add(trData);
|
||||
}
|
||||
}
|
||||
return new ApiResult<List<OriginAccountOnlineModel>>(retData);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error(title, ex.Message + "-->info:" + info);
|
||||
return new ApiResult<List<OriginAccountOnlineModel>>(ResultCode.C_INVALID_ERROR, "查询失败");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 踢号
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<bool> KillOut( string id)
|
||||
{
|
||||
var client = CreateHttpClient();
|
||||
var title = GetOpTitle("KillOut", id);
|
||||
var info = "";
|
||||
try
|
||||
{
|
||||
var url = string.Format(this.KIllUrl, id);
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
if(content.Has()&&content.IndexOf("断开成功")!=-1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error(title, ex.Message + "-->info:" + info);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否存在
|
||||
/// </summary>
|
||||
/// <param name="account"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<bool> Exist(string account)
|
||||
{
|
||||
var client = CreateHttpClient();
|
||||
var title = GetOpTitle("Exist", account);
|
||||
LogHelper.Info(title, account);
|
||||
|
||||
|
||||
string url = $"userapi3/?secretId={secretId}&secretKey={secretKey}&type=getuserlenNum&user={account}";
|
||||
var resp = await client.GetAsync(url);
|
||||
var content = await resp.Content.ReadAsStringAsync();
|
||||
JObject jo = (JObject)JsonConvert.DeserializeObject(content);
|
||||
var status = jo["code"].ToString();
|
||||
if (status == "1")
|
||||
{
|
||||
var count = jo["count"].ToInt();
|
||||
return count > 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user