GithubHelp home page GithubHelp logo

plivo-dotnet's Introduction

Plivo C# .NET Helper Library

Description

The Plivo C# .NET helper simplifies the process of making PLIVO API calls and generating RESTXML.

See Plivo Documentation for more information.

Installation

This package can be installed using NuGet package manager in Visual Studio 2010 or later.

NuGet terminal

PM> Install-Package Plivo

How to use

Plivo.API

using System;
using System.Collections.Generic;
using System.Reflection;
using RestSharp;
using Plivo.API;
	
namespace mywebapp
{
    class Program
	{
        static void Main(string[] args)
        {
            string authId=XXXXXXXXXXXXXXXXXXXXXXXX;
            string authToken=YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY;
                            				
            // Creating the plivo client
            RestAPI plivo = new RestAPI(authId, authToken);
                             
            // Making a Call
            string from_number = "XXXXXXXXXXX";
            string to_number = "YYYYYYYYYYY";
                                               				
            IRestResponse<Call> response = plivo.make_call(new Dictionary<string, string>() {
                { "from", from_number },
                { "to", to_number }, 
                { "answer_url", "http://some.domain.com/answer/" }, 
                { "answer_method", "GET" }
            });
            
            // The "Outbound call" API response has four properties -
            // message, request_uuid, error, and api_id.
            // error - contains the error response sent back from the server.
            if (resp.Data != null)
            {
                PropertyInfo[] properties = resp.Data.GetType().GetProperties();
                foreach (PropertyInfo property in properties)
                    Console.WriteLine("{0}: {1}", property.Name, property.GetValue(resp.Data, null);
            }
            else
                // ErrorMessage - contains error related to network failure.
                Console.WriteLine(resp.ErrorMessage);
            //Console.Read();
        }
    }
}

Plivo.XML

using System;
using System.Collection.Generic;
using Plivo.XML;
    
namespace myrestxml
{
    class Program
    {
        static void Main(string[] args)
        {
            Response response = new Response();
            // add 'Speak' element to 'Response'
            response.AddSpeak("Go green, go Plivo", 
                new Dictionary<string, string>() {
                    { "loop", "3" },
                    { "language", "en-US");
            });
            // or you can add as below
            //Speak speak = new Speak("Go green, go Plivo", 
            //   new Dictionary<string, string>() {
            //        { "loop", "3" },
            //        { "language", "en-US");
            //});
            //response.Add(speak);
            Console.WriteLine(response.ToString());
            Console.Read();
        }
    }
}

plivo-dotnet's People

Watchers

Rasel Jabbar avatar James Cloos avatar

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.