| Tropo WebAPI Development Guide | Home | Frameset Home |
|
numbertodial=14075550100, the numbertodial variable in your application will be set to 14075550100. When using POST, you can define variables within the request body, which will be treated the same way. Check out the Additional Reading at the bottom of this page for more info.numbertodial, customername, and msg. The code is written to accept those variables in certain places to complete the app. When the following app is launched, it will send a text message to the number defined in the URL that says “OMG John Dyer, an earthquake!”, then disconnect.https://api.tropo.com/1.0/sessions?action=create&token=TOKEN&numbertodial=14075550100&customername=John+Dyer&msg=an+earthquake
require 'tropo-webapi-ruby'
require 'sinatra'
post '/index.json' do
v = Tropo::Generator.parse request.env["rack.input"].read
to = "+" + v[:session][:parameters][:numbertodial]
name = v[:session][:parameters][:customername]
msg = v[:session][:parameters][:msg]
t = Tropo::Generator.new
t.call(:to => to, :network => "SMS")
t.say(:value => "OMG " + name + ", " + msg + "!")
t.response
end
var http = require('http');
var tropo_webapi = require('tropo-webapi');
var server = http.createServer(function (request, response) {
request.addListener('data', function(data){
json = data.toString();
});
request.addListener('end', function() {
var session = JSON.parse(json);
var tropo = new TropoWebAPI();
var to = "+" + session.session.parameters.numbertodial;
var name = session.session.parameters.customername;
var msg = session.session.parameters.msg;
//to, answerOnMedia, channel, from, headers, name, network, recording, required, timeout
tropo.call(to, null, null, null, null, null, "SMS", null, null, null);
tropo.say("OMG " + name + ", " + msg + "!");
response.end(TropoJSON(tropo));
});
}).listen(8000);
<?php
require 'tropo.class.php';
$session = new Session();
$to = "+".$session->getParameters("numbertodial");
$name = $session->getParameters("customername");
$msg = $session->getParameters("msg");
$tropo = new Tropo();
$tropo->call($to, array('network'=>'SMS'));
$tropo->say("OMG ".$name.", ".$msg."!");
return $tropo->RenderJson();
?>
from itty import *
from tropo import Tropo, Session
@post('/index.json')
def index(request):
s = Session(request.body)
t = Tropo()
t.call(to="+" + s.parameters['numbertodial'], network = "SMS"))
t.say("OMG " + s.parameters['customername'] + ", " + s.parameters['msg'] + "!")
return t.RenderJson()
run_itty(server='wsgiref', host='0.0.0.0', port=8888)
| ANNOTATIONS: EXISTING POSTS |
egblue
|
|
| Is there a way to know if a parameter is defined? How would you do that in Javascript?
parameter_name == undefined doesn't exist. Thanks, |
|
VoxeoBrianChurch
|
|
| Hello,
I'm forwarding this issue to our Tropo team so that they can help you find a solution as soon as possible. In the meantime, if you have any other questions or concerns that we can address for you, please don't hesitate to ask us. Regards, Brian Church Customer Support Engineer Voxeo Corporation |
|
kbond
|
|
| Hello,
Are you trying to extract the parameters from the HTTP request that initiates your app? If you are, there will always be parameters - "action" = "create" and "token" = "You apps token". You can use these variables as if they are already declared in your app. You can see an example on this from the URL below: https://www.tropo.com/docs/rest/starting_session.htm Is that what you are looking for? If not, please explain and give examples of your questions and issues. Besides that, if you have any other questions or concerns, please don't hesitate to ask! Regards, Kevin Bond Voxeo Labs |
| login |
|