I am trying to implement Tropo into my MVC4 application. I have a simple Gateway that creates a call to a number and says a message. I can't seem to get it working, all that happens is Tropo dials the number and hangs up when the person answers.
Here is my Gateway code:
public void SendAppointmentNotification()
{
var httpWReq =
(HttpWebRequest)WebRequest.Create("https://api.tropo.com/v1/sessions");
var encoding = new ASCIIEncoding();
var postDataTemplate = "<session>" +
"<token>{0}</token>" +
"<var name=\"numberToDial\" value=\"{1}\"></var>" +
"<var name=\"msg\" value=\"{2}\"></var>" +
"</session>";
var tokenToUse = [APIKEY]-Removed;
var numberToDial = "XXXXXXXXXX";
var message = "Greetings. This is a reminder that you have a service call appointment scheduled.";
var postData = string.Format(postDataTemplate, tokenToUse, numberToDial, message);
var data = encoding.GetBytes(postData);
httpWReq.Method = "POST";
httpWReq.Accept = "text/xml";
httpWReq.ContentType = "text/xml";
httpWReq.ContentLength = data.Length;
var newStream = httpWReq.GetRequestStream();
newStream.Write(data, 0, data.Length);
var response = (HttpWebResponse) httpWReq.GetResponse();
byte[] buffer = new byte[response.ContentLength];
using (var stream = response.GetResponseStream())
{
stream.Read(buffer, 0, (int) response.ContentLength);
}
var bufferAsString = buffer.Aggregate("", (current, t) => current + (char) t);
if (response.StatusCode != HttpStatusCode.OK)
{
throw new Exception("Did not get status OK 200 from POST");
}
newStream.Close();
}
Tropo's site seems to show much love to all languages other than C# and the Github repository they have is quite old and lacks documentation.
I just want to call a person and say a message... has anyone been down this road and can offer me some example of their implementation?