string[] strArray = PhoneNO.Split(','); //字符串转数组
string uuid = System.Guid.NewGuid().ToString("N");
DateTime startTime = TimeZoneInfo.ConvertTimeToUtc(new DateTime(1970, 1, 1, 8, 0, 0));//北京所在东八区
DateTime endTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now);
MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes("api_id=" + select3[7].Value + "&api_key=" + select3[8].Value + "&request_id=" + uuid + "×tamp=" + Convert.ToInt64((endTime - startTime).TotalSeconds) + ""));
StringBuilder sBuilder = new StringBuilder();
for (int i = 0; i < data.Length; i++)
{
sBuilder.Append(data[i].ToString("x2"));//转化为小写的16进制
}
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(PostUrl);
myRequest.Method = "POST";
myRequest.ContentType = "application/json";
using (var streamWriter = new StreamWriter(myRequest.GetRequestStream()))
{
string json = new JavaScriptSerializer().Serialize(new
{
api_id = select3[7].Value,
signature = sBuilder.ToString(),
timestamp = Convert.ToInt64((endTime - startTime).TotalSeconds),
request_id = uuid,
product_id = 1018,
phone = strArray,
sign_name = "签名名称",
content = Name
});
streamWriter.Write(json);
}
var response = (HttpWebResponse)myRequest.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
string res = reader.ReadToEnd();
}
else
{
//访问失败
}
验证码已发送到您的手机,请查收!
输入验证码后,点击“开通体验账户”按钮可立即开通体验账户。