46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Support.Controllers
|
|
{
|
|
public static class Https
|
|
{
|
|
public static Models.Version GetVersion(string _url)
|
|
{
|
|
Models.Version result = null;
|
|
|
|
try
|
|
{
|
|
if(!string.IsNullOrEmpty(_url))
|
|
{
|
|
string url = _url.Replace("/exchange/key", "") + "/exchange/key";
|
|
|
|
using (WebClient client = new WebClient())
|
|
{
|
|
ServicePointManager.ServerCertificateValidationCallback = (a, b, c, d) => true;
|
|
var reqparm = new System.Collections.Specialized.NameValueCollection();
|
|
byte[] responsebytes = client.UploadValues(url, "POST", reqparm);
|
|
string response = Encoding.UTF8.GetString(responsebytes);
|
|
|
|
if(!string.IsNullOrEmpty(response))
|
|
{
|
|
result = JsonConvert.DeserializeObject<Models.Version>(response);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine(ex.Message);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|