public void Page_Load(object sender, EventArgs args) { // Create a new instance of the Tropo object. Tropo tropo = new Tropo(); // Call the say method of the Tropo object and give it a prompt to say. //tropo.Say("Hello World!"); List <String> to = new List <String>(1); to.Add("sip:[email protected]:5678"); to.Add("sip:[email protected]:5678"); Message message = new Message(); message.To = to; message.From = "sip:[email protected]"; message.Say = new Say("I am a message 1"); message.PromptLogSecurity = "suppress"; message.Voice = "en-us"; tropo.Message(message); tropo.RenderJSON(Response); }
protected void Page_Load(object sender, EventArgs e) { // Create a new instance of the Tropo object. Tropo tropo = new Tropo(); // Set the voice to use when saying a prompt. tropo.Voice = Voice.UsEnglishMale_Steven; // A prompt to give the say to the recipient. Say say = new Say("This is a reminder call. Remember, you have a meeting at 2 PM"); // An ArrayList to hold the numbers to call (first call answered hears the prompt). List <String> to = new List <String>(); to.Add("3055195825"); to.Add("3054445567"); // Create an endpoint object to denote who the call is from. string from = "7777777777"; // Call the message method of the Tropo object and pass in values. tropo.Message(say, to, false, Channel.Voice, from, "reminder", Network.Pstn, true, 60); // Render the JSON for Tropo to consume. Response.Write(tropo.RenderJSON()); }
/// <summary> /// Must be used from an endpoint URL. /// This will parse the active session and send the specified messages. /// As of now, it only supports sending through the MSN Network IM /// </summary> /// <param name="reader"></param> /// <param name="messages"></param> /// <returns></returns> public static string ExecuteSession(StreamReader reader, Dictionary <string, List <string> > messages) { string sessionJSON = reader.ReadToEnd(); Tropo tropo = new Tropo(); try { Session tropoSession = new Session(sessionJSON); foreach (var kvp in messages) { string to = kvp.Key; string from = "*****@*****.**"; foreach (string msg in kvp.Value) { tropo.Message(new Say(msg), new List <string>() { to }, false, Channel.Text, from, from, Network.Msn, false, 30); } } } catch { } return(tropo.RenderJSON()); }
public void testMessageUseAllOptions() { Say say = new Say("This is an announcement"); Tropo tropo = new Tropo(); tropo.Voice = Voice.BritishEnglishFemale_Kate; string from = "3055551212"; List <String> to = new List <String>(); to.Add("3055195825"); tropo.Message(say, to, false, Channel.Text, from, "foo", Network.SMS, true, 10, "voicee", "none"); Assert.AreEqual(this.messageJsonAllOptions, renderJSONToText(tropo)); }
public void testMessage() { Say say = new Say("This is an announcement"); Tropo tropo = new Tropo(); tropo.Voice = Voice.BritishEnglishFemale_Kate; string from = "3055551212"; List <String> to = new List <String>(); to.Add("3055195825"); tropo.Message(say, to, false, Channel.Text, from, null, Network.SMS, null, 10); Assert.AreEqual(this.messageJson, tropo.RenderJSON()); }
public void testMessageFromObject() { Say say = new Say("This is an announcement"); string from = "3055551212"; Message message = new Message(); List <String> to = new List <String>(); to.Add("3055195825"); message.Say = say; message.To = to; message.From = from; message.AnswerOnMedia = false; message.Channel = Channel.Text; message.Network = Network.SMS; message.Timeout = 10; Tropo tropo = new Tropo(); tropo.Voice = Voice.BritishEnglishFemale_Kate; tropo.Message(message); Assert.AreEqual(this.messageJson, tropo.RenderJSON()); }
public void Page_Load(object sender, EventArgs args) { using (StreamReader reader = new StreamReader(Request.InputStream)) { // Create a new instance of the Tropo object. Tropo tropo = new Tropo(); // Get the JSON submitted from Tropo. string sessionJSON = TropoUtilities.parseJSON(reader); try { // Create a new Session object and pass in the JSON submitted from Tropo. Session tropoSession = new Session(sessionJSON); // Get parameters submitted with Session API call. string numberToDial = tropoSession.Parameters.Get("numberToDial"); //numberToDial = "5093176303"; string sendFromNumber = tropoSession.Parameters.Get("sendFromNumber"); //sendFromNumber = "14082041999"; string channel = tropoSession.Parameters.Get("channel"); string network = tropoSession.Parameters.Get("network"); string textMessageBody = tropoSession.Parameters.Get("textMessageBody"); string[] week = new string[4]; week[0] = "http://artifacts.voxeolabs.net.s3.amazonaws.com/test/test.png"; week[1] = "this is MessageTest这是第二行"; week[2] = "https://www.travelchinaguide.com/images/photogallery/2012/beijing-tiananmen-tower.jpg"; week[3] = "Today is 13 Aug"; //week[3] = "https://me888dia.giphy.com/media/LHZyixOnHwDDy/giphy.gif"; List <String> to = new List <String>(1); to.Add(numberToDial); to.Add("14084654399"); string currenT = DateTime.Now.ToString("yyyy/MM/dd HH:MM tt"); Say say = new Say(); say.Value = "this is MMS test for webapi Csharp SDk sent @ " + currenT; say.Media = week; Message message = new Message(); message.To = to; message.From = sendFromNumber; message.Network = Network.MMS; message.Say = say; message.PromptLogSecurity = "suppress"; message.Voice = "en-us"; tropo.Message(message); } catch (JsonReaderException ex) { EventLog log = new EventLog(); log.Source = "TROPOWEBAPI"; log.WriteEntry("Tropo WebAPI Exception " + ex.Message, EventLogEntryType.Error); Response.StatusCode = 500; tropo.Say("An error occured in the application. Bad JSON"); } catch (Exception ex) { EventLog log = new EventLog(); log.Source = "TROPOWEBAPI"; log.WriteEntry("Tropo WebAPI Exception " + ex.Message, EventLogEntryType.Error); Response.StatusCode = 500; tropo.Say("An error occured in the application."); } finally { tropo.RenderJSON(Response); } } }