Guest User

Untitled

a guest
Jun 20th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Web;
  4. using System.Xml;
  5. using TropoCSharp.Structs;
  6. using TropoCSharp.Tropo;
  7.  
  8. namespace OutboundTest
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. // The voice and messaging tokens provisioned when your Tropo application is set up.
  15. string textToken = "enter-your-messaging-token-here";
  16. string voiceToken = "enter-your-voice-token-here";
  17.  
  18. // A collection to hold the parameters we want to send to the Tropo Session API.
  19. IDictionary<string, string> parameters = new Dictionary<String, String>();
  20.  
  21. // Enter a phone number to send a call or SMS message to here.
  22. parameters.Add("sendToNumber", "1112223333");
  23.  
  24. // Set the number the message will come from.
  25. parameters.Add("fromNumber", "4445556666");
  26.  
  27. // Select the channel you want to use via the Channel struct.
  28. string channel = Channel.Voice;
  29. parameters.Add("channel", channel);
  30.  
  31. // Message is sent as a query string parameter, make sure it is properly encoded.
  32. parameters.Add("msg", HttpUtility.UrlEncode("What do you know?"));
  33.  
  34. // Add a customer name to use as part of the message.
  35. parameters.Add("customerName", HttpUtility.UrlEncode("Joe"));
  36.  
  37. // Instantiate a new instance of the Tropo object.
  38. Tropo tropo = new Tropo();
  39.  
  40. // Create an XML doc to hold the response from the Tropo Session API.
  41. XmlDocument doc = new XmlDocument();
  42.  
  43. // Set the token to use.
  44. string token = channel == Channel.Text ? textToken : voiceToken;
  45.  
  46. // Load the XML document with the return value of the CreateSession() method call.
  47. doc.Load(tropo.CreateSession(token, parameters));
  48.  
  49. // Display the results in the console.
  50. Console.WriteLine("Result: " + doc.SelectSingleNode("session/success").InnerText.ToUpper());
  51. Console.WriteLine("Token: " + doc.SelectSingleNode("session/token").InnerText);
  52. Console.Read();
  53. }
  54. }
  55. }
Add Comment
Please, Sign In to add comment