-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.php
More file actions
84 lines (70 loc) · 2.45 KB
/
index.php
File metadata and controls
84 lines (70 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
include 'Services/Twilio/Capability.php';
$accountSid = 'YourTwilioAccountSID';
$authToken = 'YourTwilioAuthToken';
$capability = new Services_Twilio_Capability($accountSid, $authToken);
$capability->allowClientOutgoing('YourTwilioAppSID');
$capability->allowClientIncoming("YourTwilioClientName");
$token = $capability->generateToken();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1.0">
<title>Twilio Client Browser Phone</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js" type="text/javascript" ></script>
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript" src="//static.twilio.com/libs/twiliojs/1.2/twilio.min.js"></script>
<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 call() {
// 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>
</head>
<body>
<table align="center">
<tr>
<td>
<h1>Twilio Browser Phone</h1>
<form>
<table class="table">
<tr>
<td>
<input class="input-xlarge" type="text" id="client_to_number" name="client_to_number" placeholder="発信先電話番号を入力してください。">
<br/>
<button class="btn btn-large btn-primary" type="button" id="client_callBtn" name="client_callBtn" onclick="call();">発信</button>
<button class="btn btn-large btn-primary" type="button" id="client_hangBtn" name="client_hangBtn" onclick="hangup();">切断</button>
<div id="log">Loading pigeons...</div>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>