I am creating asp,net MVC application, one of the requirements is to send bulk sms from cell numbers stored in in database. I got Twilio Send SMS Messages in C# and .NET via REST API, but i have no idea how to use this in MVC, Here is the code:
using System;
using System.Collections.Generic;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Types;
namespace Quickstart
{
class SmsSender
{
static void Main(string[] args)
{
const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
const string authToken = "your_auth_token";
TwilioClient.Init(accountSid, authToken);
var people = new Dictionary<string, string>() {
{"+14158675309", "Curious George"},
{"+14158675310", "Boots"},
{"+14158675311", "Virgil"}
};
// Iterate over all our friends
foreach (var person in people)
{
// Send a new outgoing SMS by POSTing to the Messages resource
MessageResource.Create(
from: new PhoneNumber("555-555-5555"), // From number, must be an SMS-enabled Twilio number
to: new PhoneNumber(person.Key), // To number, if using Sandbox see note above
// Message content
body: $"Hey {person.Value} Monkey Party at 6PM. Bring Bananas!");
Console.WriteLine($"Sent message to {person.Value}");
}
}
}
}
I will appreciate your assistance.