• Welcome to RadioDJ - Free Radio Automation Software Forum. Please log in or sign up.

TuneIn API Integration

Started by afrodread, July 17, 2014, 09:01:08 PM

afrodread

Has anyone found a work around for intergrating a plugin for 'TuneIn API Integration ? Here is the link to the info: http://tunein.com/broadcasters/api/

Would be thankful if somenone can enlighten me how l can intergrate it.

Marius

The link you've posted is pretty self explanatory.

You must send a link in this format:
http://air.radiotime.com/Playing.ashx?partnerId=<id>&partnerKey=<key>&id=<stationid>&title=Bad+Romance&artist=Lady+Gaga

Open Now Playing info and in Web Export tab enter this:

On URL:
http://air.radiotime.com/Playing.ashx

On Custom Data:
partnerId=<id>&partnerKey=<key>&id=<stationid>&title=$title$&artist=$artist$

Make sure that you replace the <id> <key> and <stationid> with your data.

Set method to GET and check the Enable check-box.
DOWNLOADS PAGE

HOW TO FIX RADIODJ DATABASE
----------------
Please don't PM me for support requests. Use the forums instead.

HMC

Quote from: Marius on July 17, 2014, 09:14:27 PM
The link you've posted is pretty self explanatory.

You must send a link in this format:
http://air.radiotime.com/Playing.ashx?partnerId=<id>&partnerKey=<key>&id=<stationid>&title=Bad+Romance&artist=Lady+Gaga

Open Now Playing info and in Web Export tab enter this:

On URL:
http://air.radiotime.com/Playing.ashx

On Custom Data:
partnerId=<id>&partnerKey=<key>&id=<stationid>&title=$title$&artist=$artist$

Make sure that you replace the <id> <key> and <stationid> with your data.

Set method to GET and check the Enable check-box.

To further add to this. If you already have a link in the web exporter like I do that goes to my server, You'll probably need to have that file send the info once you receive it.

For instance, I use a PHP file to receive my data and do stuff with it. In that same file I will add a CURL function to send the api info to Tune-in and still have everything done at once.
Radio DJ 1.7.5 Update with MariaDB 10

AndyDeGroo

I have it implemented in my web data pusher using Curl wrapper class like so:

<?php
require_once 'lib/curl.class.php';
require_once 
'lib/curl_response.class.php';

// TuneIn API info (these were sent to me via email after request)
$StationID "s######";
$PartnerId "########";
$PartnerKey "######";

// some irrelevant code omitted...

$artist = isset($_GET['artist'])? $_GET['artist'] : '';
$title = isset($_GET['title'])? $_GET['title'] : '';

// other irrelevant code...

if(!empty($title) && !empty($artist)) {

    
$curl = new Curl;
    
$curl->options = array(
        
'autoreferer' => true,
        
'curlopt_timeout' => 10,
        
'CURLOPT_USERAGENT' => 'PHP/'.phpversion(),
    );
    
$curl->headers = array(
        
'Accept' => '*/*',
        
'Cache-Control' => 'no-cache',
        
'Pragma' => 'no-cache',
        
'Connection' => 'close',
    );

    
// TuneIn API call
    
$tuneIn_url "http://air.radiotime.com/Playing.ashx";
    
$tuneInArgs = array(
        
"partnerId" => $PartnerId,
        
"partnerKey" => $PartnerKey,
        
"id" => $StationID,
        
'artist' => $artist,
        
'title' => $title,
    );
    
$response $curl->get($tuneIn_url$tuneInArgs);
    if(
$response->headers['Status-Code'] == 200){
        echo 
"OK - Update sent successfully";
    }else{
        echo 
"Update failed.\nResponse:\n".$response->body;
    }
}
?>



HMC

Quote from: AndyDeGroo on July 17, 2014, 11:07:12 PM
I have it implemented in my web data pusher using Curl wrapper class like so:

<?php
require_once 'lib/curl.class.php';
require_once 
'lib/curl_response.class.php';

// TuneIn API info (these were sent to me via email after request)
$StationID "s######";
$PartnerId "########";
$PartnerKey "######";

// some irrelevant code omitted...

$artist = isset($_GET['artist'])? $_GET['artist'] : '';
$title = isset($_GET['title'])? $_GET['title'] : '';

// other irrelevant code...

if(!empty($title) && !empty($artist)) {

    
$curl = new Curl;
    
$curl->options = array(
        
'autoreferer' => true,
        
'curlopt_timeout' => 10,
        
'CURLOPT_USERAGENT' => 'PHP/'.phpversion(),
    );
    
$curl->headers = array(
        
'Accept' => '*/*',
        
'Cache-Control' => 'no-cache',
        
'Pragma' => 'no-cache',
        
'Connection' => 'close',
    );

    
// TuneIn API call
    
$tuneIn_url "http://air.radiotime.com/Playing.ashx";
    
$tuneInArgs = array(
        
"partnerId" => $PartnerId,
        
"partnerKey" => $PartnerKey,
        
"id" => $StationID,
        
'artist' => $artist,
        
'title' => $title,
    );
    
$response $curl->get($tuneIn_url$tuneInArgs);
    if(
$response->headers['Status-Code'] == 200){
        echo 
"OK - Update sent successfully";
    }else{
        echo 
"Update failed.\nResponse:\n".$response->body;
    }
}
?>



Yes like this. Good example. I may use the class it looks cleaner. Didn't know about it. I just do regular curl setup with PHP.
Radio DJ 1.7.5 Update with MariaDB 10

nchuijg

Andy,

Can i use this script in a local installed USBWebserver, thats where my realtime playlist is generated and transformed to html and ftp uploaded, to my webside.

http://members.ziggo.nl/nchuijg/page1.htm

I am not so into PHP.

Greetings Nico

AndyDeGroo

Quote from: HMC on July 18, 2014, 03:34:02 AM
Yes like this. Good example. I may use the class it looks cleaner. Didn't know about it. I just do regular curl setup with PHP.

While this curl class is easier to use than regular curl, what example is from an older script. Now I use different Curl class which is similar, but even easier to use and it's still maintained.

Quote from: nchuijg on July 18, 2014, 02:07:50 PM
Can i use this script in a local installed USBWebserver, thats where my realtime playlist is generated and transformed to html and ftp uploaded, to my webside.
Sure, you may use it. Just remember that the Curl class is needed for this script to function.
I don't get it why do you have to generate playlist and then upload it using FTP. Sounds exactly like what SAM does and, IMHO, it's awkward. Can't you use PHP to serve dynamic pages on your web site?

nchuijg

Quote from: AndyDeGroo on July 18, 2014, 08:14:11 PM
I don't get it why do you have to generate playlist and then upload it using FTP. Sounds exactly like what SAM does and, IMHO, it's awkward. Can't you use PHP to serve dynamic pages on your web site?

Andy,
No, the free homepage service from my internet provider Ziggo only has html, i have to make a account by a professional web provider, mayby in the future.

Thanks for de script, first i will get the partner ID and key from TuneIn than ill gif it a try.

Greetings Nico.

nchuijg

Andy,

I think that curl Class for me a little to high class is, put the question here, is it possible only with a php script sutch nowplaying give TuneIn the played information.
I use RadioDJ version 1.6.5.7.

Nico.

Marius

#9
DOWNLOADS PAGE

HOW TO FIX RADIODJ DATABASE
----------------
Please don't PM me for support requests. Use the forums instead.

HMC

#10
Curl might be overkill for that. You can use file_get_contents for the same thing. It should work.

example PHP code. You would have to send the artist and title from the web exporter. You would fill in your partnerkey, partnerid and stationid in the URL.


<?php
$artist 
urlencode(stripcslashes($_POST["artist"]));
$title urlencode(stripcslashes($_POST["title"]));

$url "http://air.radiotime.com/Playing.ashx?partnerId=<id>&partnerKey=<key>&id=<stationid>&title=".$title."&artist=".$artist;

file_get_contents($url);
?>

Radio DJ 1.7.5 Update with MariaDB 10

nchuijg

Hi HMC,

What do you mean with: "You would have to send the artist and title from the web exporter" is there a another program involved or only the script wil do?
I have to ask my partner ID and partner key from TuneIn yet, so after that i can test it.

Thanks so far, Greetings Nico.


AndyDeGroo

Quote from: nchuijg on July 19, 2014, 03:08:09 PM
Hi HMC,

What do you mean with: "You would have to send the artist and title from the web exporter" is there a another program involved or only the script wil do?
I have to ask my partner ID and partner key from TuneIn yet, so after that i can test it.

Thanks so far, Greetings Nico.
By "web exporter" HMC meant Now Playin Info > Web Export tab in RadioDJ. See this thread on how to set it up.

nchuijg

Andy,

Thanks, i understand, i use the text output for the edcast encoders, so i have to use  the next tap, web exporter for this, ill give it a try.

Greetings Nico.

nchuijg

Quote from: HMC on July 19, 2014, 01:04:39 AM
Curl might be overkill for that. You can use file_get_contents for the same thing. It should work.

example PHP code. You would have to send the artist and title from the web exporter. You would fill in your partnerkey, partnerid and stationid in the URL.


<?php
$artist 
urlencode(stripcslashes($_POST["artist"]));
$title urlencode(stripcslashes($_POST["title"]));

$url "http://air.radiotime.com/Playing.ashx?partnerId=<id>&partnerKey=<key>&id=<stationid>&title=".$title."&artist=".$artist;

file_get_contents($url);
?>



Hi HMC,

I try out the webexport, first the way with the script from Marius to generate default NowPlaying as config in Options, it generate in data.txt the Nowplaying string.
After that i change it to read custom data (see picture) i start up your script and it give the following errors,

Notice: Undefined index: artist in C:\USBWebserver v8.6\root\TuneIn\TuneIn API.php on line 2

Notice: Undefined index: title in C:\USBWebserver v8.6\root\TuneIn\TuneIn API.php on line 3

I don't see anything about the password in that script from you, could that be the problem, i do know nothing from php so i need some help, please.

Greetings Nico.


[attachment deleted by admin]