-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslack.php
25 lines (19 loc) · 967 Bytes
/
slack.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
<?php
require_once "root.php";
require_once "resources/require.php";
require_once "vendor/autoload.php";
$settings = json_decode(file_get_contents(__DIR__."/settings.json"), true);
if(!isset($_POST['token']) || $_POST['token'] != $settings['slack']['token']) {
error_log("Invalid token ".$_POST['token']);
die("Invalid token");
}
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if (!$fp) {
die("Failed to connect");
}
if(isset($_POST['text'])) {
$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
$number = $phoneUtil->parse($_POST['text'], "US");
$number_str = $phoneUtil->format($number, \libphonenumber\PhoneNumberFormat::E164);
event_socket_request($fp, "api originate sofia/gateway/".$settings['origination']['gateway']."/".$settings['origination']['prefix'].$number_str." '&bridge(user/".$settings['on_air_user']."@".$settings['on_air_domain'].")'");
}