123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Net.Security;
- using System.Security.Cryptography.X509Certificates;
- using System.Text;
- using Library;
- // using MongoDB.Bson;
- // using MongoDB.Driver;
- // using MongoDB.Driver.Linq;
- namespace MySystem
- {
- public class BankCardCheck
- {
- public readonly static BankCardCheck Instance = new BankCardCheck();
- private BankCardCheck()
- {
- }
- private const String host = "https://bankcard4c.shumaidata.com";
- private const String path = "/bankcard4c";
- private const String method = "GET";
- private const String appcode = "8e5704921ca3422f80f0deb935a7ddc6";
- public string Do(string bankcard, string idcard, string mobile, string name)
- {
- String querys = "bankcard=" + bankcard + "&idcard=" + idcard + "&mobile=" + mobile + "&name=" + name;
- String bodys = "";
- String url = host + path;
- HttpWebRequest httpRequest = null;
- HttpWebResponse httpResponse = null;
- if (0 < querys.Length)
- {
- url = url + "?" + querys;
- }
- if (host.Contains("https://"))
- {
- ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
- httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
- }
- else
- {
- httpRequest = (HttpWebRequest)WebRequest.Create(url);
- }
- httpRequest.Method = method;
- httpRequest.Headers.Add("Authorization", "APPCODE " + appcode);
- if (0 < bodys.Length)
- {
- byte[] data = Encoding.UTF8.GetBytes(bodys);
- using (Stream stream = httpRequest.GetRequestStream())
- {
- stream.Write(data, 0, data.Length);
- }
- }
- try
- {
- httpResponse = (HttpWebResponse)httpRequest.GetResponse();
- }
- catch (WebException ex)
- {
- httpResponse = (HttpWebResponse)ex.Response;
- }
- Stream st = httpResponse.GetResponseStream();
- StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
- string result = reader.ReadToEnd();
- return result;
- }
- public bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
- {
- return true;
- }
- }
- }
|