Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Web;
- using System.Xml;
- using TropoCSharp.Structs;
- using TropoCSharp.Tropo;
- namespace OutboundTest
- {
- class Program
- {
- static void Main(string[] args)
- {
- // The voice and messaging tokens provisioned when your Tropo application is set up.
- string textToken = "enter-your-messaging-token-here";
- string voiceToken = "enter-your-voice-token-here";
- // A collection to hold the parameters we want to send to the Tropo Session API.
- IDictionary<string, string> parameters = new Dictionary<String, String>();
- // Enter a phone number to send a call or SMS message to here.
- parameters.Add("sendToNumber", "1112223333");
- // Set the number the message will come from.
- parameters.Add("fromNumber", "4445556666");
- // Select the channel you want to use via the Channel struct.
- string channel = Channel.Voice;
- parameters.Add("channel", channel);
- // Message is sent as a query string parameter, make sure it is properly encoded.
- parameters.Add("msg", HttpUtility.UrlEncode("What do you know?"));
- // Add a customer name to use as part of the message.
- parameters.Add("customerName", HttpUtility.UrlEncode("Joe"));
- // Instantiate a new instance of the Tropo object.
- Tropo tropo = new Tropo();
- // Create an XML doc to hold the response from the Tropo Session API.
- XmlDocument doc = new XmlDocument();
- // Set the token to use.
- string token = channel == Channel.Text ? textToken : voiceToken;
- // Load the XML document with the return value of the CreateSession() method call.
- doc.Load(tropo.CreateSession(token, parameters));
- // Display the results in the console.
- Console.WriteLine("Result: " + doc.SelectSingleNode("session/success").InnerText.ToUpper());
- Console.WriteLine("Token: " + doc.SelectSingleNode("session/token").InnerText);
- Console.Read();
- }
- }
- }
Add Comment
Please, Sign In to add comment