Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending Message Using Twilio-C#

Tags:

c#

twilio

Hy... I'm learning twilio rightnow, and I have seen a post here http://www.markhagan.me/Samples/Send-SMS-Using-Twilio-ASPNet

I have made my own code because in above site "sendSMSMessage" is deprecated now, but Here is my code :

using System.Text;
using System.Threading.Tasks;
using Twilio;
namespace SMSUsingTwilio
{
    class Program
    {
        static void Main(string[] args)
        {
            String ACCOUNT_SID = "ACMYSID"; 
            String AUTH_TOKEN = "40MYAUTHTOKEN";

            TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);

            Message Response = client.SendMessage("(732)305-8856", "+6285220446195", "Hellow Hyosoka Poipo :D");
            

            Console.WriteLine(Response.Status);
            Console.WriteLine(Response.AccountSid);
            
            Console.WriteLine("SMS Berhasil di kirim");
            Console.ReadLine();    
        }
    }
}

The problem is I don't any sms message to my phone number and even I don't get any response in my C# project: enter image description here

So what's wrong here...?? Please help..Thank you so much...:)

like image 879
Maryadi Poipo Avatar asked Aug 23 '26 13:08

Maryadi Poipo


2 Answers

After seeing mr.David answer, I realized that my phone number was not yet verified. So go to this link for verifying my number:

https://www.twilio.com/user/account/phone-numbers/verified

After that, I run my project agian and here is the result : enter image description here

Yeeeiii...Thanks so much for your comments and answer... I really appreciate it... :)

like image 68
Maryadi Poipo Avatar answered Aug 25 '26 02:08

Maryadi Poipo


The above looks fine:

var message = client.SendMessage("(732)305-8856", "+6285220446195", "Hellow Hyosoka Poipo :D");

Example:

static void Main(string[] args) 
{ 
    string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; 
    string AuthToken = "[AuthToken]"; 
    var twilio = new TwilioRestClient(AccountSid, AuthToken); 

    var message = twilio.SendMessage("(732)305-8856", "+6285220446195", "Hellow Hyosoka Poipo :D"); 
    ); 
    Console.WriteLine(message.Sid); 
 } 

Check this out: https://www.twilio.com/docs/api/rest/sending-messages

I don't recognise your phone numbers, if the above example does not work it will be an issue with your account or the number format.

like image 35
David Avatar answered Aug 25 '26 01:08

David