What is Twilio and Sending SMS with it in C# and ASP.NET

What is Twilio and Sending SMS with it in C# and ASP.NET

In this tutorial we will explain you how to use Twilio to send SMS using C# and ASP.NET. You can send SMS to any phone no and anywhere in the world. Let us first introduce you to Twilio.

What is Twilio

Twilio allows to make and receive phone calls and send and receive text messages using its APIs. Programmers can implement Twilio APIs in their code and create all sort of applications involving phone calls and SMS. It’s services are accessed over HTTP and are billed based on usage. It can be used easily in our application for creating features like SMS authentication, OTP, SMS marketing and more.

Twilio SMS

In this tutorial we will create a simple code which will send SMS to a mobile no using Twilio API.
Follow the steps outlined below –

STEP 1:- Create your account in Twilio to get API credentials.

STEP 2: – Reference the Twilio.Api.dll file in your website. You can download this file by clicking here. Alternately you can also reference this file from Visual Studio Nuget Package Manager Console. Type ‘Install-Package Twilio’ and press enter key.

twilio api

Installing Twilio from NuGet

STEP 3:- Add reference to Twilio namespace in your web page.

Eg . using Twilio;

STEP4:- Add the following code in your page load event.

  
protected void Page_Load(object sender, EventArgs e)
    {
	 string AccountSid = "Your Twilio Account Sid";
        string AuthToken = "Your Twilio Auth Token";
        var twilio = new TwilioRestClient(AccountSid, AuthToken);
        var message = twilio.SendMessage("+13343164589", "+919818924213", "Jenna please?! I love you", "");
    }

Note that in the above twilio.SendMessage() function has 3 parameters –

a) First Parameter – the twilio phone numbers which you can get from the twilio website. The cost of this number starts from $1 per month.

b) Second Parameter – the number to which you have to send SMS.

c) Third Parameter – the SMS message

For using helper libraries in other languages like php, perl, C++, phython, Java etc visit – https://www.twilio.com/docs/libraries

Share this article -

yogihosting

ABOUT THE AUTHOR

This article has been written by the Technical Staff of YogiHosting. Check out other articles on "WordPress, SEO, jQuery, HTML" and more.

Enter your email address

Subscribe to this blog and receive notifications of new posts by email. Join over 81,000 other subscribers

Don't worry we won't spam.

subscribers