API response format

pimas

New member
Hi Dimitri.

I had some issues when reading API response format from a website. Because some are in XML format and others are in plain text, Javascript can't handle both formats in the same function, as it stops if an error is found.

So, I came up with a simple solution:
1) Passing all the requestes through a route PHP script that receives the URL command, checks if it is ok, and then sends it to RB port.
2) RB sends back the response either in XML or Text. The route script looks for the XML tag, and if there isn't any it's a text response.
3) A browser header is set according to the received format and the response is sent to the website.
This solution is perfect and solves 2 major problems: Using SSL protocol with the request, and formating the output header.

But this isn't a solution to everyone. The header issue is important to fix, so it can be read by javascript without errors by any simple script.

The TODO for RB:
Setting header params for the response before it is sent, the same way you do to files.

The workarround PHP code:
-------------------------------------------------------------------
function doTask($api,$cmd)
{
$handle = fopen($api.$cmd, "rb");
$resp = stream_get_contents($handle);
fclose($handle);
return $resp;
}

$xml = doTask($api,"?".$action.$pwd);
if ( strpos($xml,"?xml") ) {
header("Content-type: text/xml; charset=utf-8");
} else {
header("Content-type: text/html; charset=utf-8");
}
echo $xml;
-------------------------------------------------------------------

If anyone else is having this issue, this might be useful.

Other stuff:
Dimitri, you're doing a great job. API is a great tool! I managed to control RB from a website, including playlist managing, setting sheduler events, play requests, and performimg live shows from remote locations without any attendant at RB computer.
I'm having so much fun coding all this features to the website. I don't need to be at RB computer. Only need a browser to run the radiostation.

If you need more info on this, PM me.
Regards.
 

djsoft

Well-known member
Staff member
RadioBOSS already sets the headers for responses. Do you use the latest version? If so, please tell what API commands do not set the proper header.

pimas said:
Dimitri, you're doing a great job. API is a great tool!
Thank you! Please let me know if some commands are missing, or have to be improved.
 

pimas

New member
Sorry for the late reply.

I'm workng whith RB v5.6.2.0 because I experienced some sudden reboots with the latest version.
This could be caused by an old WinXP-SP3, or other running services such as a Webserver and FTP server.
When I downgraded the version, the reboots stoped.

The issue of the XML/Text header, can also be an Apache miss configuration. But it only happens with RB and not in the Webserver environment (websites). I mention this, because the response is sent via Apache/PHP and not directly from API.

Currently I'm working on a Joomla 3.x component to control RB.
A backend with the most sensitive actions such as Scheduler, Encoders, Reboots, Poscasts, and many more.
A frontend with basic actions to allow radio hosts to perform live acts from anywere in the world. By sending their stream IP into the playlist as next track, they can go live by them selves.
They can also trigger sweepers the same way as in Cart Tab.
(frontend preview attached)

djsoft said:
Please let me know if some commands are missing, or have to be improved.

Yes, I do have a list of missing actions and tasks that can improve API.
Let you know as soon as I'll write it down.

Thanks for your support.
 

Attachments

  • emissao.png
    emissao.png
    557.2 KB · Views: 275

djsoft

Well-known member
Staff member
pimas said:
I'm workng whith RB v5.6.2.0 because I experienced some sudden reboots with the latest version.
This could be caused by an old WinXP-SP3, or other running services such as a Webserver and FTP server.
When I downgraded the version, the reboots stoped.
There shouldn't be any reboots. Please try the latest RadioBOSS 5.7.1 - there are many API improvements, new commands and some existing commands improved. If you still experience reboots, please click Help->Contact support->Send bug reports.

pimas said:
The issue of the XML/Text header, can also be an Apache miss configuration.
RadioBOSS does not communicate with Apache, it uses its own internal HTTP server to handle API requests and responses. RadioBOSS 5.7 or later fixes the header problem.

pimas said:
Currently I'm working on a Joomla 3.x component to control RB.
This looks interesting. Will it be published or it's a private project?
 

pimas

New member
Hi Dimitri.

djsoft said:
There shouldn't be any reboots. Please try the latest RadioBOSS 5.7.1 - there are many API improvements, new commands and some existing commands improved.
Did the recomended upgrade when you advised me. Works perfect. Good job on tracking those bugs.

djsoft said:
RadioBOSS does not communicate with Apache, it uses its own internal HTTP server to handle API requests and responses. RadioBOSS 5.7 or later fixes the header problem.
Will test it soon... Thank you.

djsoft said:
This looks interesting. Will it be published or it's a private project?
Started as a private projet, but it is becoming the "Swiss knife" of RadioBOSS that everyone should have. My problem is, where will I distribute the Component. To be listed in JED (Joomla! Extensions Directory), I most have a landing page to showcase the features, and give support... Unfortunly I have no time for that.

How is the project going?
The frontend is almost done and in final version, with the features you already know.
Note: No database used. All data is delivered by RadioBOSS.

Backend features:
- Scheduler:
  * Background and font colors as set in application
  * Search Group / Event Name
  * Enable / Disable events on-the-fly
  * Ads hidden from list
  * Event settings as icon view
  * Run event
  * Delete event

- Library:
  * Lists ALL items (slower if 4000+ items)
  * Search Artist, Title or Genre
  * Send Track to Playlist as Enqueue or Next Play

- System Tools:
  * Insert URL Feed in Playlist
  * Enable / Disable Scheduler
  * (in development)

- Cartwall:
  * Set unlimited action buttons
  * 2 areas to place buttons
  * (in development)

- Playlist:
  * Currently playing track marked as "ON AIR"
  * Item actions disabled on previous tracks
  * Can push previous tracks to below the current track area, but not above it
  * Move tracks anywhere below Current Track, but not to above it (same as remove track)
  * Set track as Next Play
  * Remove track from Playlist

For better insight, see attachment.

As you requested here is a list of API requests:
- songrequest : needs streamingtitle to set a costum requested title
- scheduler upcoming next : single or multiple events in a new XML response
- playbakinfo : Next Play -> if user set, send position (by order if more than one)

Bugs in V5.7.1:
- When shuffle playlist (Shift+Ctrl+S), current track should go to top of list
 

Attachments

  • RadioBOSS Dashboard.png
    RadioBOSS Dashboard.png
    89.1 KB · Views: 303

djsoft

Well-known member
Staff member
pimas said:
songrequest : needs streamingtitle to set a costum requested title
In this case, it will require some moderation, as users will be able to enter any text and use it as a title on your radio.

pimas said:
- scheduler upcoming next : single or multiple events in a new XML response
This is already possible: you can get the list of events and sort them by "IntTimeToStart" field - the less the value, the sooner the event will start.

pimas said:
playbakinfo : Next Play -> if user set, send position (by order if more than one)
Can you please provide more information on this?

pimas said:
When shuffle playlist (Shift+Ctrl+S), current track should go to top of list
I'm not sure about it. Currently it only does the shuffling, no other changes are applied.
 
Top