-
Notifications
You must be signed in to change notification settings - Fork 144
/
Server.example.php
54 lines (40 loc) · 1.33 KB
/
Server.example.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
<?php
/**
* @author Amir Sanni <[email protected]>
* @date 4th November 2019
*/
class Server
{
public function index()
{
$servers = $this->getIceServers();
header('Content-Type: Application/json');
echo json_encode(json_decode($servers)->v->iceServers);
}
private function getIceServers()
{
// PHP Get ICE STUN and TURN list
$data = ["format"=>"urls"];
$json_data = json_encode($data);
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_HTTPHEADER => ["Content-Type: application/json", "Content-Length: " . strlen($json_data)],
CURLOPT_POSTFIELDS => $json_data,
CURLOPT_URL => "https://global.xirsys.net/_turn/YOUR-CHANNEL-NAME",//Replace 'YOUR-CHANNEL-NAME' with the name of your xirsys channel
CURLOPT_USERPWD => "YOUR PASSWORD",
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_SSL_VERIFYPEER => TRUE
]);
$res = curl_exec($curl);
if(curl_error($curl)){
echo "Curl error: " . curl_error($curl);
};
curl_close($curl);
return $res;
}
}
$server = new Server;
$server->index();