Skip to content

Instantly share code, notes, and snippets.

@twilioforkwc
Last active September 22, 2015 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twilioforkwc/e9e098eba18231595f59 to your computer and use it in GitHub Desktop.
Save twilioforkwc/e9e098eba18231595f59 to your computer and use it in GitHub Desktop.
<script type="text/javascript">
Twilio.Device.setup("<?php echo $token; ?>");
Twilio.Device.ready(function (device) {
$("#log").text("架電待機");
});
Twilio.Device.error(function (error) {
$("#log").text("Error: " + error.message);
});
Twilio.Device.connect(function (conn) {
$("#log").text("架電成功");
});
Twilio.Device.disconnect(function (conn) {
$("#log").text("架電終了");
});
Twilio.Device.incoming(function (conn) {
if (confirm('Accept incoming call from ' + conn.parameters.From + '?')){
connection=conn;
conn.accept();
}
});
function clientCall() {
// get the phone number to connect the call to
params = {"PhoneNumber": $("#client_to_number").val()};
Twilio.Device.connect(params);
}
function hangup() {
Twilio.Device.disconnectAll();
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment