static void Main(string[] args)
        {
            string token = "your-voice-token-goes-here";
            string conferenceID = "my-test-conference";

            // An array of numbers to call and join to the conference.
            string[] numbersToCall = new string[] { "13034567890", "13034567891" };

            // SIP endpoint for a simple Tropo JavaScript app to play a message to the conference. See README file
            string conferenceTimer = "sip:[email protected]";

            // the length of time to wait before playing the conference message.
            int timer = 60000;
            
            // A collection to hold the parameters we want to send to the Tropo Session API.
            IDictionary<string, string> parameters = new Dictionary<String, String>();

            // 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();

            // Add the conferencce ID to the paramters collection.
            parameters.Add("conferenceID", conferenceID);

            foreach (string number in numbersToCall)
            {
                // Add the number to call to the parameters collection.
                parameters.Add("callToNumber", number);

                // Make API call.
                Console.WriteLine("Sending API request for: " + number);
                doc.Load(tropo.CreateSession(token, parameters));
                Console.WriteLine("Result: " + doc.SelectSingleNode("session/success").InnerText.ToUpper());
                Console.WriteLine("Token: " + doc.SelectSingleNode("session/token").InnerText);
                Console.WriteLine("=============================");

                // Remove the callToNumber key so we can reset in next loop.
                parameters.Remove("callToNumber");                
            }

            // Sleep for x seconds.
            Thread.Sleep(timer);

            // Send reminder message to the conference.
            Console.WriteLine("Sending conference time reminder.");
            parameters.Add("callToNumber", conferenceTimer);
            doc.Load(tropo.CreateSession(token, parameters));
            Console.WriteLine("Result: " + doc.SelectSingleNode("session/success").InnerText.ToUpper());
            Console.WriteLine("Token: " + doc.SelectSingleNode("session/token").InnerText);
            Console.WriteLine("=============================");

            Console.Read();
        }
示例#2
0
        static void Main(string[] args)
        {
            // The voice and messaging tokens provisioned when your Tropo application is set up.
            string voiceToken = "your-voice-token-here";
            string messagingToken = "your-messaging-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", "15551112222");

            // Enter a phone number to use as the caller ID.
            parameters.Add("sendFromNumber", "15551113333");

            // Select the channel you want to use via the Channel struct.
            string channel = Channel.Text;
            parameters.Add("channel", channel);

            string network = Network.SMS;
            parameters.Add("network", network);

            // Message is sent as a query string parameter, make sure it is properly encoded.
            parameters.Add("msg", HttpUtility.UrlEncode("This is a test message from C#."));

            // 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 ? messagingToken : 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();
        }
示例#3
0
        static void SMSTest()
        {
            // The voice and messaging tokens provisioned when your Tropo application is set up.
            string voiceToken = "24cfa15afd01ab4489c7b18a0480219c850af8c4d484deb1978682945803be78c8238c963a7541d19c6745fe";
            string messagingToken = "24cfab7873517444b6458ab707aed2a778989481fc39c5100008b7b3a193b0aa05d0ce9e8aa3422862ced55c";

            // 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", "14046416658");

            // Enter a phone number to use as the caller ID.
            parameters.Add("sendFromNumber", "17708290383");

            // Select the channel you want to use via the Channel struct.
            string channel = Channel.Text;
            parameters.Add("channel", channel);

            string network = Network.SMS;
            parameters.Add("network", network);

            // Message is sent as a query string parameter, make sure it is properly encoded.
            parameters.Add("msg", System.Web.HttpUtility.UrlEncode("This is a test message from C#."));

            // 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 ? messagingToken : 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();
        }