ASP.NET: Send SMS using asp.net MVC using Plivo

Standard

Sending SMS from ASP.NET MVC application using Plivo service is pretty easy.

Benefits

Receive Free Incoming SMS

Receive free inbound SMS messages on all Plivo SMS phone numbers in all of our coverage areas.

Personalized Sender ID

Brand your SMS messages by customizing your sender ID using alphanumeric letters characters.

SMS Short Codes

Send thousands of A2P SMS messages (e.g., two-factor authentication, systems alerts) instantly at a default base rate of 40 SMS per second.

Two-way SMS

Send and receive SMS on Plivo phone numbers in 19 countries with Short Codes available in US and Canada.

Installation:

  • Install Plivo from Nuget package manager or console:
    Install-Package Plivo

    2016-09-06-12_23_58-mvcsmssample-sln-manage-nuget-packages

    Get Free Trial Account:

    • Fill form at Sign up for free
    • You will receive AUTH_ID, AUTH_TOKEN and Sender Approved Number 

Code:

using Plivo.API;
using RestSharp;

public String TestPlivo(SmsModel obj)
{
     obj.Sender = "Approved_Sender_Number";
     RestAPI plivo = new RestAPI("AUTH_ID", "AUTH_TOKEN");
 
     IRestResponse<MessageResponse> resp = plivo.send_message(new Dictionary<string, string>()
     {
         { "src", obj.Sender }, // Sender's phone number with country code
         { "dst", obj.Reciever }, // Receiver's phone number wiht country code
         { "text", obj.Message }, // Your SMS text message
         { "url", "http://example.com/report/"}, // The URL to which with the status of the message is sent
         { "method", "POST"} // Method to invoke the url
      });
 
      return !string.IsNullOrEmpty(resp.Content) 
             ? resp.Content + resp.Data.message_uuid[0] + resp.Data.api_id 
             : "Failed";
}

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s