欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#實(shí)現(xiàn)如何使用短信平臺(tái)自動(dòng)通知用戶實(shí)例

 更新時(shí)間:2020年02月25日 09:49:59   作者:chunchunlaila  
這篇文章主要介紹了C#實(shí)現(xiàn)如何使用短信平臺(tái)自動(dòng)通知用戶實(shí)例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧

目前市面上的第三方短信服務(wù)平臺(tái)數(shù)量十分龐大,并能為企業(yè)提供三網(wǎng)合一的短信接口,這些服務(wù)商通過(guò)整合短信發(fā)送服務(wù),簡(jiǎn)單的打包成為API和SDK接口提供給企業(yè),企業(yè)只需要在自己公司的平臺(tái)上接入這些接口就可以實(shí)現(xiàn),短信平臺(tái)自動(dòng)發(fā)送的功能,企業(yè)接入這些短信平臺(tái)接口的流程十分簡(jiǎn)單,方式也不復(fù)雜。

使用中昱維信第三方平臺(tái)接口

平臺(tái)通過(guò)第三方公司提供接口實(shí)現(xiàn)短信群發(fā),以下為中昱維信的短信群發(fā)示例:

 var client = new RestClient("https://vip.veesing.com/smsApi/group?appId=35LC8QJRI2YR&appKey=YKU2JJCN4KD9BEHN&phone=18302999492&content=【中昱維信】您的短信群發(fā)功能已開(kāi)通,請(qǐng)?jiān)?個(gè)工作日之內(nèi)至平臺(tái)進(jìn)行企業(yè)認(rèn)證!");
      //構(gòu)建post請(qǐng)求
      var request = new RestRequest(Method.POST);
      //設(shè)置請(qǐng)求頭部參數(shù)
      request.AddHeader("cache-control", "no-cache");
      request.AddHeader("Connection", "keep-alive");
      request.AddHeader("Content-Length", "0");
      request.AddHeader("Accept-Encoding", "gzip, deflate");
      request.AddHeader("Host", "vip.veesing.com");
      request.AddHeader("Postman-Token", "77d8b8d3-7fe6-4dee-a157-f42701ee4cbe,04f24c10-e7da-4ca7-9729-e6e727770c9f");
      request.AddHeader("Cache-Control", "no-cache");
      request.AddHeader("Accept", "*/*");
      request.AddHeader("User-Agent", "PostmanRuntime/7.19.0");
      IRestResponse response = client.Execute(request);
      Console.WriteLine(response);
      Console.ReadKey();

平臺(tái)通過(guò)第三方公司提供接口實(shí)現(xiàn)短信群發(fā),以下為中昱維信的短信驗(yàn)證示例:

 var client = new RestClient("https://vip.veesing.com/smsApi/verifyCode?appId=35LC8QJRI2YR&appKey=YKU2JJCN4KD9BEHN&phone=18302999492&templateId=540&variables=1234");
      var request = new RestRequest(Method.POST);
      request.AddHeader("cache-control", "no-cache");
      request.AddHeader("Connection", "keep-alive");
      request.AddHeader("Content-Length", "0");
      request.AddHeader("Accept-Encoding", "gzip, deflate");
      request.AddHeader("Host", "vip.veesing.com");
      request.AddHeader("Postman-Token", "77d8b8d3-7fe6-4dee-a157-f42701ee4cbe,04f24c10-e7da-4ca7-9729-e6e727770c9f");
      request.AddHeader("Cache-Control", "no-cache");
      request.AddHeader("Accept", "*/*");
      request.AddHeader("User-Agent", "PostmanRuntime/7.19.0");

C#調(diào)用第三方平臺(tái)實(shí)現(xiàn)發(fā)送驗(yàn)證碼

private void button2_Click(object sender, EventArgs e)
    {
      if (textBox1.Text == "" || textBox1.Text.Length != 11)//手機(jī)號(hào)輸入框
      {
        MessageBox.Show("請(qǐng)輸入正確的手機(jī)號(hào)碼");
      }
      else
      {
        //生成一個(gè)隨機(jī)數(shù) 四位的
        Random random = new Random();
        int value = random.Next(1000, 10000);//用rad生成大于等于1000,小于等于9999的隨機(jī)數(shù);
        string suijishu = value.ToString(); //轉(zhuǎn)化為字符串;
        shu = suijishu;
        var client = new ZhenziSmsClient("https://sms_developer.zhenzikj.com", "你的appId", "你的appSecret");
        var parameters = new Dictionary<string, string>();
        parameters.Add("message", "尊敬的用戶:您的驗(yàn)證碼為 " + suijishu);
        parameters.Add("number", textBox1.Text);
        //parameters.Add("clientIp", "792.168.2.222");
        //parameters.Add("messageId", "");
        var result = client.Send(parameters);
        string v = result.ToString().Substring(8, 1);
        if (v == "0")
        {
          MessageBox.Show("短信發(fā)送成功");
          timer1.Start();
        }
        else
        {
          MessageBox.Show("短信驗(yàn)證碼發(fā)送失敗");
        }
      }
    }

下面是計(jì)時(shí)器timer1的代碼:

int i = 60;
    private void timer1_Tick(object sender, EventArgs e)
    {
      
      if (i == 0)
      {
        timer1.Stop();
        button2.Text = "獲取驗(yàn)證碼";
        button2.Enabled = true;
      }
      else 
      {
        i--;
        button2.Text = i.ToString ();
        button2.Enabled = false;
      }
    }
 

登錄按鈕的具體代碼:

 public static string shu;
  if (shu == textBox2.Text)//驗(yàn)證碼輸入框
      {
        MessageBox.Show("登錄成功");
      }
      else
      {
        MessageBox.Show("登錄失敗");
      }

到此這篇關(guān)于C#實(shí)現(xiàn)如何使用短信平臺(tái)自動(dòng)通知用戶實(shí)例的文章就介紹到這了,更多相關(guān)C# 短信自動(dòng)通知用戶 內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家! 

相關(guān)文章

最新評(píng)論