Skip to content

Instantly share code, notes, and snippets.

View mheadd's full-sized avatar

Mark Headd mheadd

View GitHub Profile
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>jQuery / Phono Sample</title>
<style type="text/css">
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.phono.js"></script>
// If the channel selected is TEXT, send a message.
if(channel == 'TEXT')
{
log("*** Sending text message. ***");
message("Hello, " + customerName + ", " + msg, { to: sendToNumber, network: "SMS"} );
}
// If the channel selected is Voice, make a call.
else
{
log("*** Making outbound phone call. ***");
@mheadd
mheadd / OutboundTest.cs
Created November 6, 2010 19:09
A simple C# console application to initiate SMS and Phone messages with Tropo
using System;
using System.Collections.Generic;
using System.Web;
using System.Xml;
using TropoCSharp.Structs;
using TropoCSharp.Tropo;
namespace OutboundTest
{
class Program
<?php
wait(3000);
answer();
say('Hello, sending your message now.');
message("Hi, this is a test message.", array("to" => "6512345432", "network" => "SMS"));
say('good bye');
hangup();
?>
<?php
// The URL where the test-auth.php script resides.
define("POST_DATA_TO_URL", "http://someurl/my-script.php");
// Function to send value to my-script.php script via cURL with digest authentication.
function submitValue($myValue) {
$ch = curl_init(POST_DATA_TO_URL);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
curl_setopt($ch, CURLOPT_USERPWD, "admin:mypass");
<?php
define("COUCH_DB_HOST", "");
define("COUCH_DB_PORT", "");
define("COUCH_DB_NAME", "");
function saveData($question, $to, $answer) {
$doc = json_encode(array("question" => $question, "to" => $to, "answer" => $answer, ));
$url = COUCH_DB_HOST.":".COUCH_DB_PORT."/".COUCH_DB_NAME;
@mheadd
mheadd / outbound-node.js
Created December 10, 2010 19:13
A simple Node.js script to send SMS messages through the Tropo platform.
/**
* Simple outbound message launcher in Node.js
*
* You will need to have a Tropo scripting aplication set up
* to use this. See sample code below:
*
* message(msg, { to:number, network:"SMS" });
*
* Save this file in your Tropo account as message.js
*
@mheadd
mheadd / tropo-bayeaux.html
Created December 17, 2010 19:07
Tropo / Bayeux Example for real time web connections
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Bayeux / Comet Test for Tropo</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<script type="text/javascript" src="http://path/to/your/bayeaux/server/tropo.js"></script>
<script type="text/javascript">
$(document).ready(function() {
@mheadd
mheadd / right-way.js
Created December 20, 2010 22:05
Moving from blocking functional programming, to non-blocking Node.js programming.
var sys = require('sys');
var http = require('http');
var EventEmitter = require('events').EventEmitter;
TropoSession = function() {
this.responseBody;
};
TropoSession.prototype = new EventEmitter;
@mheadd
mheadd / grammar-test.php
Created December 28, 2010 18:41
A sample Tropo application that captures a street address through speech recognition
<?php
// Get the zip code from the caller.
$zip = ask("Say your 5 digit zip code", array("choices" => "[5 DIGITS]"));
// Get the address, using a dynamically generated grammar for the user zip code.
$address = ask("What is your street address, beginning with your street number?",
array("choices" => "http://path/to/web/host/streets.php?zip={$zip->value}"));
// Write the address to the logger.