-
Notifications
You must be signed in to change notification settings - Fork 7
/
example5_clicktocall.php
59 lines (46 loc) · 1.57 KB
/
example5_clicktocall.php
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
<?
// DIY Click-To-Call using the 46elks platform
function newCall ($call) {
// Set your 46elks API username and API password here
// You can find them at https://dashboard.46elks.com/
$username = 'u2c11ef65b429a8e16ccb1f960d02c734';
$password = 'C0ACCEEC0FAFE879189DD5D57F6EC348';
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => "Authorization: Basic ".
base64_encode($username.':'.$password). "\r\n".
"Content-type: application/x-www-form-urlencoded\r\n",
'content' => http_build_query($call),
'timeout' => 5
)));
return false !== file_get_contents(
'https://api.46elks.com/a1/Calls', false, $context );
}
$call = array(
// Put one of your 46elks numbers here
'from' => '+46766861001',
// For real world, you might want to restrict this to only allow one country
'to' => $_POST['mobilenumber'],
// Destination phone number
'voice_start' => '{"connect":"+461890510"}'
);
?>
<html>
<body style="font-family: Verdana; max-width: 380px;">
<? if(!$_POST['mobilenumber']): ?>
<h2>Click-To-Call example</h2>
<p>
Enter your phone number in the box and you will receive a call.
When you answer, you will connected to +461890510 for free.
<form method="POST" action="?">
<input type="text" name="mobilenumber" value="+4670">
<input type="submit" value="Start call">
</form>
</p>
<? else: ?>
<h1>Initiating call.. Answer your phone.</h1>
<? newCall ($call); ?>
<? endif; ?>
</body>
</html>