public static void Main()
string ClientName = "mk";
string Password = "9299mk";
string Keyword = "GEMEZZS";
string ShortCode = "95799";
string dateTime = DateTime.UtcNow.AddHours(+7).ToString("yyyyMMddHHmmss");
if (!string.IsNullOrWhiteSpace(ShortCode))
Password = CreateMD5(Password);
string accessToken = ClientName + Keyword + ShortCode + dateTime + Password;
accessToken = accessToken.ToUpper();
accessToken = CreateMD5(accessToken);
if (!string.IsNullOrWhiteSpace(ShortCode))
requestURL = "http://223.27.128.222/INAPSMSToken/GetToken?AccessToken=" + accessToken + "&Keyword=" + Keyword + "&ShortCode=" + ShortCode + "&DateTime=" + dateTime;
requestURL = "http://sgp.etracker.cc/SGDCBToken/GetToken?AccessToken=" + accessToken + "&ServiceName=" + Keyword + "&&DateTime=" + dateTime;
Console.WriteLine(requestURL);
var result = Get(requestURL);
string externalIpString = new WebClient().DownloadString("http://icanhazip.com").Replace("\\r\\n", "").Replace("\\n", "").Trim();
var externalIp = IPAddress.Parse(externalIpString);
Console.WriteLine("Whitelist this IP and try again. " + externalIp.ToString());
var split = result.Split(',');
Console.WriteLine("Token = " + split[0]);
Console.WriteLine("Expire in = " + split[1] + " seconds = " + DateTime.UtcNow.AddHours(8).AddSeconds(Convert.ToDouble(split[1])));
Console.WriteLine(result);
public static string CreateMD5(string input)
using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create())
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
byte[] hashBytes = md5.ComputeHash(inputBytes);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hashBytes.Length; i++)
sb.Append(hashBytes[i].ToString("X2"));
public static string Get(string uri)
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
return reader.ReadToEnd();