Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TwilioRestClient SendMessage not resolving

Tags:

c#

twilio

I've updated my Twilio library to latest and now SendMessage no longer resolves.

client.SendMessage("YOUR_TWILIO_NUMBER", "YOUR_NUMBER", "Ahoy from Twilio!");

How do I send a text with the current C# Twilio libarary?

like image 798
BLAZORLOVER Avatar asked Apr 13 '17 20:04

BLAZORLOVER


1 Answers

Twilio developer evangelist here.

Sounds like you've updated from version 4 to version 5 of the Twilio C# library. This was an update with breaking changes and there is a full upgrade document available here.

For sending messages you need to update to use the new MessageResource. Here's an example:

using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Types;
using System.Collections.Generic;

class Example
{
   static void Main(string[] args)
   {
        // Find your Account Sid and Auth Token at twilio.com/console
        const string accountSid = "your_account_sid";
        const string authToken = "your_auth_token";
        TwilioClient.Init(accountSid, authToken);

        var to = new PhoneNumber("+15017250604");
        var message = MessageResource.Create(
            to,
            from: new PhoneNumber("+15558675309"),
            body: "This is the ship that made the Kessel Run in fourteen parsecs?");
        Console.WriteLine(message.Sid);
   }
}

Let me know if that helps.

like image 167
philnash Avatar answered Oct 06 '22 01:10

philnash