Code Monkey home page Code Monkey logo

twilio-csharp's Introduction

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

Installation

Via NuGet

Install REST API wrapper:

Install-Package Twilio

Install ASP.NET MVC helpers and REST API wrapper:

Install-Package Twilio.Mvc

To install WebMatrix/ASP.NET Web Pages helpers, search for Twilio in the WebMatrix site administration.

Sample Usage

using Twilio;
var twilio = new TwilioRestClient("accountSid", "authToken");
var call = twilio.InitiateOutboundCall("+1555456790", "+15551112222", "http://example.com/handleCall");
var msg = twilio.SendSmsMessage("+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.SendSmsMessage("+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);

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.

twilio-csharp's People

Contributors

johnsheehan avatar joelmartinez avatar alden-quimby-zocdoc avatar barranger avatar brettgerry avatar

Watchers

 avatar

Forkers

ludwigseborn

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.