RadioDJ - Free Radio Automation Software Forum

TuneIn API Integration

TuneIn API Integration
« on: July 17, 2014, 09:01:08 PM »
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.
 
« Last Edit: July 17, 2014, 09:15:08 PM by Marius »

Offline Marius

  • *****
  • 5572
    • Radio DJ
Re: Plugin or Feature for 'TuneIn API Integration
« Reply #1 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:
Code: [Select]
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:
Code: [Select]
http://air.radiotime.com/Playing.ashx
On Custom Data:
Code: [Select]
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.

Offline HMC

  • ***
  • 181
Re: Plugin or Feature for 'TuneIn API Integration
« Reply #2 on: July 17, 2014, 10:34:26 PM »
The link you've posted is pretty self explanatory.

You must send a link in this format:
Code: [Select]
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:
Code: [Select]
http://air.radiotime.com/Playing.ashx
On Custom Data:
Code: [Select]
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

Re: TuneIn API Integration
« Reply #3 on: July 17, 2014, 11:07:12 PM »
I have it implemented in my web data pusher using Curl wrapper class like so:
Code: [Select]
<?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;
    }
}
?>


Offline HMC

  • ***
  • 181
Re: TuneIn API Integration
« Reply #4 on: July 18, 2014, 03:34:02 AM »
I have it implemented in my web data pusher using Curl wrapper class like so:
Code: [Select]
<?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

Re: TuneIn API Integration
« Reply #5 on: July 18, 2014, 02:07:50 PM »
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

Re: TuneIn API Integration
« Reply #6 on: July 18, 2014, 08:14:11 PM »
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.

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?

Re: TuneIn API Integration
« Reply #7 on: July 18, 2014, 09:36:16 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.

Re: TuneIn API Integration
« Reply #8 on: July 18, 2014, 10:28:14 PM »
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.

Offline Marius

  • *****
  • 5572
    • Radio DJ
Re: TuneIn API Integration
« Reply #9 on: July 18, 2014, 11:01:45 PM »
« Last Edit: July 25, 2014, 11:08:26 AM by Marius »
DOWNLOADS PAGE

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

Offline HMC

  • ***
  • 181
Re: TuneIn API Integration
« Reply #10 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.

Code: [Select]
<?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);
?>

« Last Edit: July 19, 2014, 01:10:52 AM by HMC »
Radio DJ 1.7.5 Update with MariaDB 10

Re: TuneIn API Integration
« Reply #11 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.


AndyDeGroo

Re: TuneIn API Integration
« Reply #12 on: July 19, 2014, 03:26:42 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.

Re: TuneIn API Integration
« Reply #13 on: July 19, 2014, 10:20:05 PM »
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.

Re: TuneIn API Integration
« Reply #14 on: July 24, 2014, 10:29:31 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.

Code: [Select]
<?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]