Skip to content

Instantly share code, notes, and snippets.

@RobSpectre
Created January 10, 2012 04:35
Show Gist options
  • Save RobSpectre/1586979 to your computer and use it in GitHub Desktop.
Save RobSpectre/1586979 to your computer and use it in GitHub Desktop.
Your TwiML application - "APxxxxx"
<Response>
<Play>sound_file.mp3</Play>
</Response>
<?php
include 'Services/Twilio/Capability.php';
// put your Twilio API credentials here
$accountSid = 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$authToken = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy';
$capability = new Services_Twilio_Capability($accountSid, $authToken);
// Allow this Twilio Client to connect to the TwiML application above.
$capability->allowClientOutgoing('APxxxxxx');
$token = $capability->generateToken();
?>
<!DOCTYPE html>
<html>
<head>
<title>Hello Client Monkey 1</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("<?php echo $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");
});
function call() {
Twilio.Device.connect();
}
</script>
</head>
<body>
<button class="call" onclick="call();">
Call
</button>
<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