Created
January 2, 2012 06:55
-
-
Save lancefisher/1549646 to your computer and use it in GitHub Desktop.
ASP.NET Code running on the MacBook Pro for Twilio Rube Goldberg Contest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@using Twilio; | |
@{ | |
string accountSid = "XXXXXX"; | |
string authToken = "XXXXXX"; | |
string appSid = "XXXXXX"; | |
var capability = new TwilioCapability(accountSid, authToken); | |
capability.AllowClientOutgoing(appSid); | |
capability.AllowClientIncoming("jenny"); | |
string token = capability.GenerateToken(); | |
} | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Set the Nixie Tubes!</title> | |
<script type="text/javascript" | |
src="http://static.twilio.com/libs/twiliojs/1.0/twilio.min.js"></script> | |
<script type="text/javascript" | |
src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"> | |
</script> | |
<link href="http://static0.twilio.com/packages/quickstart/client.css" | |
type="text/css" rel="stylesheet" /> | |
<script type="text/javascript"> | |
Twilio.Device.setup('@token'); | |
Twilio.Device.ready(function (device) { | |
$("#log").text("Ready"); | |
}); | |
Twilio.Device.error(function (error) { | |
$("#log").text("Error: " + error.message); | |
}); | |
Twilio.Device.connect(function (conn) { | |
$("#log").text("Successfully established call"); | |
}); | |
Twilio.Device.disconnect(function (conn) { | |
$("#log").text("Call ended"); | |
}); | |
Twilio.Device.incoming(function (conn) { | |
$("#log").text("Incoming connection from " + conn.parameters.From); | |
// accept the incoming connection and start two-way audio | |
conn.accept(); | |
}); | |
function call() { | |
// get the phone number to connect the call to | |
params = { "PhoneNumber": $("#number").val() }; | |
Twilio.Device.connect(params); | |
} | |
function hangup() { | |
Twilio.Device.disconnectAll(); | |
} | |
</script> | |
</head> | |
<body> | |
<button class="call" onclick="call();"> | |
Call | |
</button> | |
<button class="hangup" onclick="hangup();"> | |
Hangup | |
</button> | |
<input type="text" id="number" name="number" | |
placeholder="Who want to set the nixie tubes? (phone #)"/> | |
<div id="log">Loading pigeons...</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment