-
Notifications
You must be signed in to change notification settings - Fork 2
/
atomicradio-streamstatus.php
63 lines (62 loc) · 2.65 KB
/
atomicradio-streamstatus.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
60
61
62
63
<?php
// Seeing as Java lately has been throwing SSL errors for the Dubtrack API, this is a PHP script to pull the SSL API
// pages and spit out JSON. This file is hosted on my web hosting (jsaunders.id.au/atomicradio-streamstatus.php)
// but this code is provided to show that I'm not stealing anything from you. You are more than welcome to host this
// file yourself on your webserver (requires php_curl) and change the config to reflect the new address.
// What is the script calling for?
if (isset($_GET["check"])) {
if ($_GET["check"] == "getStatus") {
// Script calling for Stream Status
if (isset($_GET["roomName"])) {
$roomName = $_GET["roomName"];
$url = "https://api.dubtrack.fm/room/" . $roomName;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$curl_response = curl_exec($ch);
print_r($curl_response);
curl_close($ch);
} else {
echo("ERROR: No Room Name specified!");
}
} else if ($_GET["check"] == "getUserID") {
// Script is calling for the User ID of the current DJ
if (isset($_GET["roomID"])) {
$roomID = $_GET["roomID"];
$url = "https://api.dubtrack.fm/room/" . $roomID . "/playlist/active";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$curl_response = curl_exec($ch);
print_r($curl_response);
curl_close($ch);
} else {
echo("ERROR: No Room ID specified!");
}
} else if ($_GET["check"] == "getUserName") {
// Script is calling for the Username of the current DJ
if (isset($_GET["userID"])) {
$userID = $_GET["userID"];
$url = "https://api.dubtrack.fm/user/" . $userID;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$curl_response = curl_exec($ch);
print_r($curl_response);
curl_close($ch);
} else {
echo("ERROR: No User ID specified!");
}
} else {
echo("ERROR: Malformed request!");
}
} else {
echo("ERROR: Malformed request!");
}
?>