using System; using System.Net.Http; using System.Threading.Tasks; using Newtonsoft.Json.Linq; class BankCard { private const string AppKey = "YOUR_APPKEY_HERE"; public static async Task QueryAsync(string bankcard) { try { // 构建请求 URL string url = $"https://api.jisuapi.com/bankcard/query?appkey={AppKey}&bankcard={bankcard}"; using (HttpClient client = new HttpClient()) { // 发送 GET 请求 HttpResponseMessage response = await client.GetAsync(url); // 确保请求成功 response.EnsureSuccessStatusCode(); // 读取响应内容 string responseBody = await response.Content.ReadAsStringAsync(); // 解析 JSON 数据 JObject jsonarr = JObject.Parse(responseBody); // 检查状态码 if (jsonarr["status"] != null && (int)jsonarr["status"] != 0) { if (jsonarr["msg"] != null) { Console.WriteLine(jsonarr["msg"]); } return; } // 获取结果对象 JObject result = (JObject)jsonarr["result"]; if (result != null) { // 输出信息 Console.WriteLine($"{result["bankcard"]} {result["name"]} {result["type"]}"); Console.WriteLine($"{result["province"]} {result["city"]}"); Console.WriteLine($"{result["bank"]} {result["logo"]} {result["tel"]}"); Console.WriteLine($"{result["website"]} {result["len"]} {result["iscorrect"]}"); } } } catch (HttpRequestException ex) { Console.WriteLine($"请求出错: {ex.Message}"); } catch (Exception ex) { Console.WriteLine($"发生错误: {ex.Message}"); } } static async Task Main(string[] args) { //await BankCard.QueryAsync('6212261202011584349'); } }