简体   繁体   English

带有 Twilio .netcore Blazor 服务器端的短信通知

[英]Sms notifications with Twilio .netcore Blazor server side

I'm looking to add sms notifications to my Blazor server side application.我希望将短信通知添加到我的 Blazor 服务器端应用程序。 My plan is to create a windows service that runs on a specified frequency;我的计划是创建一个以指定频率运行的 windows 服务; this service will check data in an Azure sql database (the data is inserted via a web api using entity framework) and send sms notifications to users if certain criteria is met.该服务将检查 Azure sql 数据库中的数据(数据通过使用实体框架的 web api 插入)并在满足特定条件时向用户发送短信通知。 My question is, what does integrating Twilio into this look like?( I've never used Twilio)我的问题是,将 Twilio 集成到其中是什么样子?(我从未使用过 Twilio)

Also, how do I setup a console app to run as a service at a specified frequency?另外,如何设置控制台应用程序以指定频率作为服务运行?

Lastly, what is best practices as far as the console app accessing my database?最后,就控制台应用程序访问我的数据库而言,最佳做法是什么?

what does integrating Twilio into this look like?( I've never used Twilio)将 Twilio 集成到其中是什么样子?(我从未使用过 Twilio)

Send SMS Messages with a Messaging Service in C# 使用 C# 中的消息服务发送 SMS 消息

// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;


class Program
{
    static void Main(string[] args)
    {
        // Find your Account Sid and Token at twilio.com/console
        // DANGER! This is insecure. See http://twil.io/secure
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var message = MessageResource.Create(
            body: "This is the ship that made the Kessel Run in fourteen parsecs?",
            from: new Twilio.Types.PhoneNumber("+15017122661"),
            to: new Twilio.Types.PhoneNumber("+15558675310")
        );

        Console.WriteLine(message.Sid);
    }
}

how do I setup a console app to run as a service at a specified frequency?如何设置控制台应用程序以指定频率作为服务运行?

The right solution for scheduling simple processes is Windows Task Scheduler .安排简单进程的正确解决方案是Windows Task Scheduler There are lots of examples about How to create an automated task using Task Scheduler有很多关于How to create an automated task using Task Scheduler的例子

Lastly, what is best practices as far as the console app accessing my database?最后,就控制台应用程序访问我的数据库而言,最佳做法是什么?

Nothing especial but connection string .没有什么特别的,只有连接字符串

"ConnectionStrings": {        
    "Database": "Server=(url);Database=CoreApi;Trusted_Connection=True;"        
  },

Create connection string 创建连接字符串

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM