Tropo SMS



Tropo scripting API allows you to program just about anything that uses voice or text. You pass parameters in the JSON body via REST, and then use those in your Tropo script, which can be javascript, ruby, python, php, or groovy.

The API itself is only 16 methods, making it remarkably simple: answer, ask, call, conference, getHeader, hangup, log, message, record, redirect, reject, say, startCallRecording, stopCallRecording, transfer, and wait. The currentCall and return objects have some further methods that allow you to act on things like callerID, callerName, callDuration, and choice.

Below is the code for the simple sms example on this page:

HTML

<form action=”/tropo.php” method=”POST”>
<input type=”text” required name=”msg” placeholder=”Message” />
<input type=”text” required name=”numberToDial” placeholder=”10 Digit Phone Number” />
<button type=”submit”>Send SMS</button></form>

PHP

<?php
$token = ‘not shown but this is the long api key’;
$body = array(‘token’ => $token, ‘msg’ => $_POST[‘msg’], ‘numberToDial’ => $_POST[‘numberToDial’]);
$json_body = json_encode($body);
$headers = array();
$headers[] = ‘Content-Type: application/json’;
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, “https://api.tropo.com/1.0/sessions”);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_body);
$server_output = curl_exec ($ch);
curl_close ($ch);

Tropo/JS

call(‘+1’ + numberToDial, {
network:”SMS”});
say(“” + msg + “”);

Read more @
https://www.tropo.com/docs/scripting/reference