小编典典

从ASP.NET网站发送SMS

c#

是否可以使用Web API从ASP.NET网站发送SMS?我了解Web服务,但不知道如何从我的应用程序调用这些服务。


阅读 316

收藏
2020-05-19

共1个答案

小编典典

Web服务是最好的方法。我在网站上使用Twilio,并且设置和工作非常容易。可伸缩性不是问题,而且您将不必花费开发人员时间来构建自己的解决方案,就可以弥补成本。

Twilio:http://www.twilio.com/

可用于.NET的Twilio库:https :
//www.twilio.com/docs/csharp/install

在twilio-csharp项目中,这是如何发送SMS的示例(我从twilio-csharp获得了此消息。只需重新发布以显示它是多么容易)。

static void Main(string[] args)
{
    TwilioRestClient client;

    // ACCOUNT_SID and ACCOUNT_TOKEN are from your Twilio account
    client = new TwilioRestClient(ACCOUNT_SID, ACCOUNT_TOKEN);

    var result = client.SendMessage(CALLER_ID, "PHONE NUMBER TO SEND TO", "The answer is 42");
    if (result.RestException != null) {
        Debug.Writeline(result.RestException.Message);
    }    
}
2020-05-19