客户会提供获取token的URL,用户名和密码
public static string getToken()
{
string url = "https://。。。。。。。。。。/token";
string KEY = "J_。。。。。。。8qdlESELldUa";
string SECRET = "SmXL。。。。。。。AyqoNPVs6ga";
// 这里不知道用的是哪个版本的SSL加密,所以把所有版本都填上
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
// 构造请求
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
request.ProtocolVersion = HttpVersion.Version11;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.Credentials = new NetworkCredential(KEY, SECRET);
// 写入数据主体
using (var writer = new StreamWriter(request.GetRequestStream