twilio-csharp 0

Twilio .NET Helper Library for .NET, ASP.NET, ASP.NET MVC and ASP.NET Web Pages (WebMatrix). Need help? Post your questions to http://stackoverflow.com/ or email us at [email protected]

Build status

Twilio REST API and TwiML Libraries for .NET, ASP.NET, ASP.NET MVC and WebMatrix

Twilio provides a simple HTTP-based API for sending and receiving phone calls and text messages. Learn more at http://www.twilio.com

.NET Helper Library Documentation

Twilio REST API Documentation - Twilio TwiML Documentation

Alpha Version

A new alpha version (v3.7.55) of the Twilio .NET library is available on nuget. This version removes the RestSharp dependency and includes a new Portable Class Library version which can be used by .NET 4.0 and newer. To install the alpha version from the NuGet Package manager console, add the -prerelease flag to the Install-Package command:

Install-Package Twilio -prerelease

Adding Twilio libraries to your .NET project

The best and easiest way to add the Twilio libraries to your .NET project is to use the NuGet package manager. NuGet is a Visual Studio extension that makes it easy to install and update third-party libraries and tools in Visual Studio.

NuGet is available for Visual Studio 2010 and Visual Studio 2012, and you can find instructions for installing the NuGet extension on the NuGet.org website:

http://docs.nuget.org/docs/start-here/installing-nuget

Once you have installed the NuGet extension, you can choose to install the Twilio libraries using either the Package Manager dialog, or using the Package Manager console.

Installing via the Package Manager Dialog

To install a Twilio library using the Package Manager dialog, first open the dialog by right-clicking the References folder in your project and selecting the package manager option:

When the package manager dialog opens simply search the online catalog for ‘Twilio’. The screen shot below shows the results returned from the NuGet catalog:

Simply click the Install button next to the Twilio package you want to add to your project and watch as NuGet downloads the Twilio library package (and its dependencies) and adds the proper references to your project.

Installing via the Package Manager Console

To install a Twilio library using the Package Manager console, first open the console, then Use the Install-Package command to install the different Twilio packages:

Install REST API wrapper:

Install-Package Twilio

Install ASP.NET MVC helpers and REST API wrapper:

Install-Package Twilio.Mvc

Installing in WebMatrix

If you are using Microsoft’s free web developer tool WebMatrix, it also includes integration with NuGet. To add the Twilio helpers to a site created using WebMatrix simply open the WebMatrix administration website (as described here). Change the Show dropdown from Installed to Online and use the search field to Search for ‘Twilio’.

Sample Usage

The examples below show how to have your application initiate and outbound phone call and send an SMS message using the Twilio .NET helper library:

using Twilio;
var twilio = new TwilioRestClient("accountSid", "authToken");
var call = twilio.InitiateOutboundCall("+1555456790", "+15551112222", "http://example.com/handleCall");
var msg = twilio.SendMessage("+15551112222", "+15553334444", "Can you believe it's this easy to send an SMS?!");

Silverlight/Windows Phone 7/Asynchronous Requests Sample

using Twilio;
var twilio = new TwilioRestClient("accountSid", "authToken");
twilio.InitiateOutboundCall("+1123456790", "+15555551212", "http://example.com/handleCall", (call) => {
    // Console.WriteLog(call.Sid);
});

twilio.SendMessage("+15555551212", "+11234567890", "Hello!", (msg) => {
    // Console.WriteLine(msg.Sid);
});

TwiML Generation with ASP.NET Sample

var response = new TwilioResponse();
response.Say("Hello Monkey");
response.Play("http://demo.twilio.com/hellomonkey/monkey.mp3");
response.BeginGather(new { numDigits = 1, action = "hello-monkey-handle-key.cshtml", method = "POST" });
response.Say("To speak to a real monkey, press 1. Press 2 to record your own monkey howl. Press any other key to start over.");
response.EndGather();

// ASP.NET MVC when controller inherits from TwilioController
return TwiML(response);

// ASP.NET MVC regular controller
return new TwiMLResult(response);

// ASP.NET Webforms
var doc = response.ToXDocument();
Response.ContentType = "application/xml";
doc.Save(Response.Output);

Getting help

If you need help installing or using the library, please contact Twilio Support at [email protected] first. Twilio's Support staff are well-versed in all of the Twilio Helper Libraries, and usually reply within 24 hours.

If you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!

Migrating from earlier versions

Migrating from original twilio/twilio-csharp (version 2.1 and below)

Moving from version 2.1 or below to 3.0 will require changes to your existing code. The library now centers around a TwilioRestClient class from which all operations you can make against the API are rooted. Refer to the [[Twilio.Api]] REST API wrapper documentation for the list of available methods.

Migrating from johnsheehan/TwilioApi

This library is derived from johnsheehan/TwilioApi. Minimal changes should be required to your code in order to use this version. The most notable change is the renaming of TwilioClient to TwilioRestClient. In addition to the REST API wrapper, this new version also includes TwiML generation and ASP.NET MVC helpers.

Developing on the library with Mono

You can setup a mono/nunit development environment using the Makefile:

Note: You will need Homebrew.

> make develop

Then, you can build the solution using xbuild:

> make

and run the tests using nunit:

> make test

Related Repositories

Warden

Warden

Define "health checks" for your applications, resources and infrastructure. Keep ...

azure-webjobs-sdk-extensions

azure-webjobs-sdk-extensions

Azure WebJobs SDK Extensions ...

ANCLAFS

ANCLAFS

ASP.NET Core Library and Framework Support ...

awesome-c-sharp

awesome-c-sharp

A curated list of awesome C-Sharp frameworks, libraries and software. ...

app-monkeychat

app-monkeychat

Monkey Chat application feature Twilio IP Messaging ...


Top Contributors

devinrader carlosdp skimbrel AlexPayment johnsheehan mplacona jingming ihumanable dougblack joelmartinez joefitzgerald Ragil MatthewSteeples dbrink-onebridge akjordan barranger brettgerry alden-quimby-zocdoc efossier peranborkett senthgit craigomatic

Releases

-   v4.0.0-CI00069 zip tar
-   v4.0.0-CI00068 zip tar
-   v4.0.0-CI00067 zip tar
-   v4.0.0-CI00065 zip tar
-   v4.0.0-CI00064 zip tar
-   v4.0.0-CI00063 zip tar
-   v4.0.0-CI00062 zip tar
-   v4.0.0-CI00055 zip tar
-   v4.0.0-CI00054 zip tar
-   v4.0.0-CI00053 zip tar
-   v4.0.0-CI00051 zip tar
-   v4.0.0-CI00050 zip tar
-   v4.0.0-CI00048 zip tar
-   v4.0.0-CI00047 zip tar
-   v4.0.0-CI00046 zip tar
-   v4.0.0-CI00045 zip tar
-   v4.0.0-CI00044 zip tar
-   v4.0.0-CI00043 zip tar
-   v4.0.0-CI00041 zip tar
-   v4.0.0-CI00040 zip tar
-   v4.0.0-CI00039 zip tar
-   v4.0.0-CI00038 zip tar
-   v4.0.0-CI00037 zip tar
-   v4.0.0-CI00035 zip tar
-   v4.0.0-CI00034 zip tar
-   v4.0.0-CI00033 zip tar
-   v4.0.0-CI00032 zip tar
-   v4.0.0-CI00031 zip tar
-   latest zip tar
-   5.0.0-rc6 zip tar