-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathnumber_answer_url.php
More file actions
68 lines (51 loc) · 1.38 KB
/
Copy pathnumber_answer_url.php
File metadata and controls
68 lines (51 loc) · 1.38 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
<?php
/*
Stringee Server gets SCCO by sending HTTP GET to this URL when someone calls your Number
/answer_url-from_external-test.php
?from=0909982888
&to=02473082686
&uuid=2297a8fa-acad-11e7-a9ba-b596eac7cf7a
&fromInternal=false
*/
$userId = @$_GET['userId'];
$from = @$_GET['from'];
$to = @$_GET['to'];
$fromInternal = @$_GET['fromInternal'];
$uuid = @$_GET['uuid'];
if($userId){
$callTo = $userId;
}else{
$callTo = 'USER_ID';
}
$scco = '[{
"action": "connect",
"from": {
"type": "external",
"number": "' . $from . '",
"alias": "' . $from . '"
},
"to": {
"type": "internal",
"number": "' . $callTo . '",
"alias": "' . $to . '"
},
"customData": "test-custom-data"
}]';
header('Content-Type: application/json');
echo $scco;
/*
$signing_secret_key = 'YOUR_SIGNING_SECRET_KEY';
$requestUri = $_SERVER['REQUEST_URI'];
$signature = @$_SERVER['HTTP_X_STRINGEE_SIGNATURE'];
function computeSignature($data, $signing_secret_key) {
$hmac = hash_hmac("sha1", $data, $signing_secret_key, true);
return base64_encode($hmac);
}
$requestUri = str_replace (' ', '%20', $requestUri);
$computedSignature = computeSignature($requestUri, $signing_secret_key);
if($computedSignature == $signature){
error_log('Confirmed to have come from Stringee');
} else {
error_log('SIGNATURE NOT VALID. It might have been spoofed');
}
*/