using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace XhOA.Untity
{
///
/// 乐秀获取Token
///
public class XhHttpClient
{
#if DEBUG
private static string name="xherp";
private static string PWD = "dee61b6f3f8d515e3fbedd094017d683273e";
private static string url = "http://106.14.62.116:13221/xhmall-dockingplatform/api";
#else
private static string name = "xherp";
private static string PWD = "dee61b6f3f8d515e3fbedd094017d683273e";
public static string url = "https://dock.xhgjmall.com/xhmall_dockingplatform/api";
#endif
public static XhToken GetToken() {
string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", DateTimeFormatInfo.InvariantInfo);
System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
string sign = BitConverter.ToString(md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(name + PWD + time + PWD))).Replace("-", "").ToLower();//MD5加密
Dictionary _params = new Dictionary()
{
{"timestamp",time }, {"username",name }, {"password",PWD }, {"sign",sign }
};
var result= HttpClient.Post(url + "/auth2/access_token", _params);
return JsonConvert.DeserializeObject(result);
}
public class XhToken {
public bool success { get; set; }
public string access_token { get; set; }
public DateTime expires_at { get; set; }
}
}
}