【问题标题】:Sms notifications with Twilio .netcore Blazor server side带有 Twilio .netcore Blazor 服务器端的短信通知
【发布时间】:2020-08-03 22:23:38
【问题描述】:

我希望将短信通知添加到我的 Blazor 服务器端应用程序。我的计划是创建一个以指定频率运行的 Windows 服务;该服务将检查 Azure sql 数据库中的数据(数据通过 Web api 使用实体框架插入),如果满足某些条件,则向用户发送短信通知。 我的问题是,将 Twilio 集成到其中是什么样子的?(我从未使用过 Twilio)

另外,如何设置控制台应用程序以指定频率作为服务运行?

最后,就控制台应用访问我的数据库而言,最佳做法是什么?

【问题讨论】:

标签: c# azure asp.net-core twilio blazor


【解决方案1】:

将 Twilio 集成到其中是什么样子的?(我从未使用过 Twilio)

Send SMS Messages with a Messaging Service in C#

// 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);
    }
}

如何设置控制台应用程序以作为服务在指定位置运行 频率?

安排简单进程的正确解决方案是 Windows 任务计划程序。 有很多关于如何使用任务计划程序创建自动化任务的示例

最后,就访问我的控制台应用程序而言,最佳做法是什么? 数据库?

没有什么特别的,只是连接字符串

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

Create connection string

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-11-25
    • 2012-06-08
    • 2013-11-11
    • 1970-01-01
    • 1970-01-01
    • 2022-06-14
    • 2013-04-24
    相关资源
    最近更新 更多