Friday, December 19, 2014

Twilio API Integration for sending SMS and List of Sent SMS


Now, you can send SMS using Twilio API easily by just following the few Steps:
Steps:
1.  Login in to the http://www.twilio.com and if you are not user then sign in.
2.  Now Open Visual Studio and start your project and download twilio and twilioML library from NuGet package installer.
3.  After Login in twilio it will gives you a “ACCOUNT SID” and “AUTH TOKEN” and also “TELEPHONE NUMBER”. Save this credentials and apply in our project as..
//you have to add namespace for twilio as like,
using twilio.com;
//and Now apply that Credentials in to our project..
String AccountSid  "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; // Account ID..
String AuthToken  "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"; // Authentication Tocken.. 
String TelephoneNo  'NNNNNNNNNN'; // Telephone No from the message will sent.
Now, Create Instance of Twilio Rest Client..
var client newTwilioRestClient($AccountSid$AuthToken);
Now, Call the Method SendSmsMessage(“Sender No with country Code”, “Receiver No with Country Code”, “Message Body…”) for sending SMS. as like,
cvar sendsms = client.sendSmsMessage(from,to,msg);
Done…. Yuppp…
Your Project is Working…..
* Note:
You can also set Validation on that like “Message length should not be greater than 160 Characters.. etc.”

Now, You can easily manage sent message list..
as below,
public SMSMessage getMessageList(String to, String from)
{
String AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; // Account ID..
String AuthToken = "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"; // Authentication Tocken..
var client = new TwilioRestClient(AccountSid,AuthToken);
SmsMessageResult msgs = postMaster.ListSmsMessages();
List msg = msgs.SMSMessages;
foreach (var smsmsg in msgs.SMSMessages)
{
 if (smsmsg.Status == “received” && smsmsg.From == from && smsmsg.To == to)
{
  return smsmsg;
}
}
 return null;
}

3 comments:

  1. Thank you so much for sharing this one really well defined all peaceful info,Regarding all kind of Wearable app Info,Mostly amazing Post share i really bookmark your blog and suggest to other's group Keep it up- Twilio API Integration

    ReplyDelete
  2. Nice post it is very useful for all. Personally I find SMS API integration very difficult but one of my friends suggested MsgClub, which offers a simple integration process and it is free of cost and send Bulk SMS API PHP.

    ReplyDelete
  3. Thanks for sharing about your interesting application,todays best and smart way to send large number of messages in single click.Bulk SMS API

    ReplyDelete