call.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. include 'Services/Twilio/Capability.php';
  3. include 'auth.php'
  4. ?>
  5. <!DOCTYPE HTML>
  6. <html>
  7. <head>
  8. <title>Phone</title>
  9. <script type="text/javascript" src="//static.twilio.com/libs/twiliojs/1.1/twilio.min.js"></script>
  10. <script type="text/javascript" src="jquery.min.js"></script>
  11. <script type="text/javascript">
  12. $(document).ready(function(){
  13. Twilio.Device.setup("<?php echo $token; ?>");
  14. $("#call").click(function() {Twilio.Device.connect();});
  15. $("#hangup").click(function() {Twilio.Device.disconnectAll();});
  16. Twilio.Device.ready(function (device) {$('#status').text('Ready to call');});
  17. Twilio.Device.offline(function (device) {$('#status').text('Offline');});
  18. Twilio.Device.error(function (error) {$('#status').text(error);});
  19. Twilio.Device.connect(function (conn) {$('#status').text("Successfully established call");toggleCallStatus();});
  20. Twilio.Device.disconnect(function (conn) {$('#status').text("Call ended");toggleCallStatus();});
  21. Twilio.Device.incoming(function (conn) {conn.accept();});
  22. function toggleCallStatus(){
  23. $('#call').toggle();
  24. $('#hangup').toggle();
  25. }
  26. });
  27. </script>
  28. </head>
  29. <body>
  30. <div align="center">
  31. <input type="button" id="call" value="Start Call"/>
  32. <input type="button" id="hangup" value="Disconnect Call" style="display:none;"/>
  33. <div id="status">
  34. Offline
  35. </div>
  36. </div>
  37. </body>
  38. </html>