in practice I had to:
1. create a Forewarding rule in the router by setting the service port (i.e. 80), local IP (the PC IP) and local port (the one in RB)
2. the php script:
in $ RB_Server put the public IP assigned to my router
in $ RB_Server put service port (80)
3. the php script provided on the site works, but in my case I had to modify it, because I had problems with my altervista.com server because it does not accept the "file_get_contents" statement so I modified the php by changing it with cURL.
Now it works with all web hosting.
------------------------->>> explanations and other ideas <<<
I would like to ask for clarifications and implementations regarding the songrequest function:
1. if this function is used automatically by the seduler, then airing when there is nobody on the radio it can be fine, indeed very well.
But I would like to understand how it could be useful for a live with the speaker who could announce the requested song.
a) practically once I get the requests in RB I display them in the request song panel (ctrl + Y)
b) if I insert a message of very few characters the speaker could read the message and then send the song to the playlist, if the message is long, the song request window (ctrl + Y) makes this reading operation inconvenient.
c) if for example I would like to insert the requested songs into playlists and then the speaker wants to announce the requested song, making the applicant's name and reading the message sent via web form, what happens, when the song request window (ctrl + y ) the song is inserted into playlists for airing, all the information regarding the message sent (which could be hello are mary and I want to dedicate this song to robert because I love it), are lost.
d) I believe that this information should always be available in some way, maybe create a specific TAB in RB (such as a notepad file) where you can set the size of the text and the rarity for easy reading live.
maybe connect with a color highlighting the song on the air required with the message of that song so as to have track that this requested song was associated with that message sent by that listener.
e) I think it is right to insert other fields in the web form which name and surname of who forward the message, this is possible by implementing the php script, but the song request is not enabled to read and show other fields on the screen.
further fields could also be the city of origin, the telephone number and other things that I do not know now.
f) we admit that I have received a list of 100 requests, is it possible to click on the various items to rearrange by artist, title, time of request?
I think that instead of "160 minute ago" better enter the date / time field 09/11/2018 at 18:07 I think it's more practical.
2. expand the PHP script so that there are some fields of research.
author, song, year, genre
For example, through the form I could search within the xml database all the songs of elvis presley, the search shows me that in the list (database) there are 30 songs, near each song I could go out a selection check, then once selected the song below I could fill in other fields such as first name (of the listener requesting the song) and then the message to send ...
so it would be easier and safer to let the artist know which tracks are available in RB
3. another interesting feature for the song request could be this:
The possibility of using a website to make a request for a song, (author - title) and instead of the text message, insert the sending of a voice audio file.
so we admit a seduler song request playlist ....
I could set ...
jingle
[song request block]
- posta_vocale.mp3 (voice message of the listener requesting the song)
- author-titolo.mp3 file
then play the jingle (optional)
first list the file associated with the request received from the website
and then the song file taken from the music library ...
the file with the voice message could be mounted on the intro of the song if sufficiently long, or it starts under a preset base, then fades the base and the song starts and the vocal ending must end on the intro of the requested song.
4. would it be an idea to create a TAB for receiving emails (text only), for the reception of messages to be read on the speaker?
or always a tab that sends messages to RB via web form? (as happens with the reception of messages in the php script for the request of songs, but in this case only and exclusively for text messages.
also for receiving messages via whatsapp (I think Whatsapp does not make this possible), or receiving via telegram etc.
<?php
/*
RadioBOSS Song Request demo script
To play the requested songs in RadioBOSS, schedule an event with "playrequestedsong" command:
http://manual.djsoft.net/radioboss/en/scheduler_commands.htm#songrequest
Please make sure the RadioBOSS API is enabled and a password is set:
http://manual.djsoft.net/radioboss/en/remote_controlapi.htm
If RadioBOSS is installed on a server, please make sure the API port (9000 by default) is allowed in firewall.
Home or studio PC:
If RadioBOSS is installed on a home or studio PC, please make sure it has a static IP address.
If a static IP address is not available, a Dynamic DNS address has to be used instead
The IP address (or dynamic DNS address) is entered into the $rb_server variable (please do not include http://)
If a computer is behing a NAT (this is usually the case when a router is used), then API port (9000 by default) has
to be forwarded in router settings - see port forwarding documentation for your router.
*/
//---------------//
// CONFIGURATION //
//---------------//
//RadioBOSS API connection details
$rb_server = '95.xxx.xxx.xxx'; //RadioBOSS hostname or IP
$rb_port = '80'; //RadioBOSS port
$rb_password = 'YdVdfWTqdH'; //API password
//music library name, omitting the .xml extension, the library is loaded from "Music library folder" as set in RadioBOSS settings
$rb_library = 'my_library_music';
//show detailed error messages (1 - show error details, 0 - show only general error messages)
//IMPORTANT! Make sure this is set to 0 once everything is configured and working to avoid revealing too many details to users!
//Error messages may contain passwords and other sensitive information
//Set this to 1 only if something's not working to get more details
$show_errors = 0;
//-------------------//
// SONG REQUEST FORM //
//-------------- ----//
//API URL base
$rb_api = "http://$rb_server:$rb_port?pass=$rb_password";
function result($msg) {
$back_link = '<a href="javascript:history.back();">Back</a>';
exit("$msg $back_link");
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>RadioBOSS Song Request demo</title>
<style>
body {
font-family: Tahoma, sans-serif;
font-size: 0.8em;
}
label {
display: block;
margin-bottom: 5pt;
}
</style>
</head>
<body>
<?php
$type = isset($_POST['type']) ? $_POST['type'] : '';
if ($type === '') {
echo '<form method="post">
<input type="hidden" name="type" value="request">
<label>Artist
<input size="30" name="artist"></label>
<label>Title
<input size="30" name="title"></label>
<label>Message
<textarea cols="30" rows="3" name="message" maxlength="13"></textarea></label>
<button>Request a song</button>
</form>';
} elseif ($type === 'request') {
//requested artist
$artist = mb_strtolower(trim($_POST['artist']));
if ($artist === '')
$artist = false;
//requested title
$title = mb_strtolower(trim($_POST['title']));
if ($title === '')
$title = false;
if (($artist === false) && ($title === false))
result('No artist or title entered.');
//Start Original Code (No Altervista)
//load library
//$library_raw = @file_get_contents("$rb_api&action=library&filename=" . urlencode($rb_library));
//if ($library_raw === false) {
// $err = 'Song request failed: unable to load music library.';
// if ($show_errors)
// $err .= ' Error: ' . error_get_last()['message'];
// result($err);
// }
//End Original Code (No Altervista)
//Start of MyCode (Si Altervista)
//load library
// Get cURL resource
$curl = curl_init();
// Set some options - we are passing in a useragent too here
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => "$rb_api&action=library&filename=" . urlencode($rb_library),
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:64.0) Gecko/20100101 Firefox/64.0'
));
// Send the request & save response to $resp
$library_raw = curl_exec($curl);
// Close request to clear up some resources
curl_close($curl);
echo $library_raw;
//End of MyCode (Si Altervista)
if ($library_raw === false) {
$err = 'Song request failed: unable to load music library.';
if ($show_errors)
$err .= ' Error: ' . error_get_last()['message'];
result($err);
}
//parse XML data
$xml = simplexml_load_string($library_raw);
if ($xml === false)
result('Song request failed: unable to parse music library XML data.');
$fn = false;
//search requested song in a music library
foreach ($xml as $x) {
if ($x->getName() !== 'Track')
continue;
$found = (($artist === false) || (mb_strtolower((string)$x['artist']) === $artist)) &&
(($title === false) || (mb_strtolower((string)$x['title']) === $title));
if ($found) {
$fn = (string)$x['filename'];
break;
}
}
//song found, add to requested songs list in RadioBOSS
if ($fn !== false) {
$msg = isset($_POST['message']) ? $_POST['message'] : '';
$res = @file_get_contents("$rb_api&action=songrequest&filename=" . urlencode($fn) . "&message=" . urlencode($msg));
if ($res === "OK")
result('Song requested successfully!');
else {
$err = 'An error occurred while adding song request.';
if ($show_errors)
$err .= ' Error: ' . error_get_last()['message'];
result($err);
}
}
else
result('Requested song not found in the music library.');
}
?>
</body>
</html>