国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C# 開發(創藍253)手機短信驗證碼接口的實例

2020-01-24 00:21:57
字體:
來源:轉載
供稿:網友

創藍253: https://www.253.com/

#region 獲取手機驗證碼(創藍253)  /// <summary>  /// 獲取手機驗證碼(創藍253)  /// </summary>  /// <param name="phoneno">手機號</param>  /// <returns></returns>  [AllowAnonymous]  public async Task<IHttpActionResult> GetPhoneCode(string phoneno)  {   string account = "******", password = "******", mobile = phoneno;   Random rd = new Random(); int r = rd.Next(100000, 999999);   string content = "【您的簽名】"+"尊敬的客戶:您的驗證碼為" + r + "!";   string postStrTpl = "un={0}&pw={1}&phone={2}&msg={3}&rd=1";   UTF8Encoding encoding = new UTF8Encoding();   byte[] postData = encoding.GetBytes(string.Format(postStrTpl, account, password, mobile, content));   HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://sms.253.com/msg/send");   myRequest.Method = "POST";   myRequest.ContentType = "application/x-www-form-urlencoded";   myRequest.ContentLength = postData.Length;   Stream newStream = myRequest.GetRequestStream();   newStream.Write(postData, 0, postData.Length);   newStream.Flush();   newStream.Close();   HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();   if (myResponse.StatusCode == HttpStatusCode.OK)   {    return Ok(new { code = "200", res = new { msg = "短信發送成功!", data = new { code = r } } });   }   else {    return Ok(new { code = "400", res = new { msg = "短信發送失敗!" } });   }  }  #endregion

以上這篇C# 開發(創藍253)手機短信驗證碼接口的實例就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 繁峙县| 桃江县| 香格里拉县| 寿宁县| 开鲁县| 康定县| 浙江省| 楚雄市| 湟源县| 台安县| 镇江市| 宜昌市| 翁源县| 哈尔滨市| 东明县| 吉木萨尔县| 拉萨市| 凤翔县| 郸城县| 拜泉县| 元氏县| 曲靖市| 宜昌市| 大同县| 普安县| 樟树市| 巩留县| 平阳县| 广水市| 安义县| 巫山县| 澄城县| 惠水县| 保亭| 布尔津县| 定襄县| 安义县| 防城港市| 邵武市| 临高县| 聂荣县|