RadioDJ - Free Radio Automation Software Forum

RadioDJ v1.7+ => Plugin Development => Topic started by: afrodread on July 17, 2014, 09:01:08 PM

Title: TuneIn API Integration
Post by: afrodread 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.
 
Title: Re: Plugin or Feature for 'TuneIn API Integration
Post by: 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:
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.
Title: Re: Plugin or Feature for 'TuneIn API Integration
Post by: HMC 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.
Title: Re: TuneIn API Integration
Post by: AndyDeGroo on July 17, 2014, 11:07:12 PM
I have it implemented in my web data pusher using Curl wrapper class (https://github.com/shuber/curl) 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;
    }
}
?>

Title: Re: TuneIn API Integration
Post by: HMC on July 18, 2014, 03:34:02 AM
I have it implemented in my web data pusher using Curl wrapper class (https://github.com/shuber/curl) 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.
Title: Re: TuneIn API Integration
Post by: nchuijg 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
Title: Re: TuneIn API Integration
Post by: AndyDeGroo 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 (https://github.com/php-curl-class/php-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 (https://github.com/shuber/curl) 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?
Title: Re: TuneIn API Integration
Post by: nchuijg 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.
Title: Re: TuneIn API Integration
Post by: nchuijg 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.
Title: Re: TuneIn API Integration
Post by: Marius on July 18, 2014, 11:01:45 PM
Maybe fsockopen() (http://php.net/manual/en/function.fsockopen.php) or file_get_contents() (http://php.net/manual/en/function.file-get-contents.php);.
Title: Re: TuneIn API Integration
Post by: 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.

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);
?>

Title: Re: TuneIn API Integration
Post by: 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.

Title: Re: TuneIn API Integration
Post by: AndyDeGroo 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 (http://www.radiodj.ro/community/index.php?topic=3440.0) on how to set it up.
Title: Re: TuneIn API Integration
Post by: nchuijg 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.
Title: Re: TuneIn API Integration
Post by: nchuijg 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]
Title: Re: TuneIn API Integration
Post by: AndyDeGroo on July 24, 2014, 11:06:55 PM
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.
It has nothing to do with password. It's normal if you see those errors when you open the page in browser. RDJ makes POST request with specified parameters, but by opening the page in browser you are sending GET request without any parameters.
Let me correct that for you:
Code: [Select]
<?php
$artist 
= isset($_POST["artist"]) ? urlencode(stripcslashes($_POST["artist"])) : '';
$title = isset($_POST["title"]) ? urlencode(stripcslashes($_POST["title"])) : '';

if(empty(
$artist) ||empty($title))
    exit(
'No data to send');

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

file_get_contents($url);
?>

Don't forget to replace <id>, <key> and <stationid> with actual values given by TuneIn.
Title: Re: TuneIn API Integration
Post by: nchuijg on July 25, 2014, 09:59:40 AM
Andy,

Thank you for your support, i understand its my lack of knowledge of php, i am now waiting for the partner id and key from TuneIn, i wil take a week or so.

Thanks greetings Nico.
Title: Re: TuneIn API Integration
Post by: AndyDeGroo on July 25, 2014, 09:23:55 PM
Thank you for your support, i understand its my lack of knowledge of php, i am now waiting for the partner id and key from TuneIn, i wil take a week or so.
You're welcome.
For me receiving the API keys took almost three weeks, but it might have been because had I sent my request on December 21st, right before holidays. I received the keys on January 9th.
It seems kinda awkward that somebody on their end has to generate the keys and send them by email instead of allowing broadcasters to register and generate the keys. Most other API services I've used (Twitter, Facebook, Google, etc.) generate keys automatically.
Title: Re: TuneIn API Integration
Post by: HMC on July 26, 2014, 04:44:14 AM
It has nothing to do with password. It's normal if you see those errors when you open the page in browser. RDJ makes POST request with specified parameters, but by opening the page in browser you are sending GET request without any parameters.
Let me correct that for you:
Code: [Select]
<?php
$artist 
= isset($_POST["artist"]) ? urlencode(stripcslashes($_POST["artist"])) : '';
$title = isset($_POST["title"]) ? urlencode(stripcslashes($_POST["title"])) : '';

if(empty(
$artist) ||empty($title))
    exit(
'No data to send');

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

file_get_contents($url);
?>

Don't forget to replace <id>, <key> and <stationid> with actual values given by TuneIn.

Thanks for making the code a little cleaner. I wrote it really quick as an "example".  But as you pointed out, it's not meant to be manually called, it's for the web exporter that sends the parameters.
Title: Re: TuneIn API Integration
Post by: nchuijg on July 30, 2014, 09:51:30 PM
You're welcome.
For me receiving the API keys took almost three weeks, but it might have been because had I sent my request on December 21st, right before holidays. I received the keys on January 9th.
It seems kinda awkward that somebody on their end has to generate the keys and send them by email instead of allowing broadcasters to register and generate the keys. Most other API services I've used (Twitter, Facebook, Google, etc.) generate keys automatically.

Hi Andy,
yesterday i receive my API key's and put them in the string on the right places, but it seems not to work, TuneIn says on there site Information does not update on the TuneIn.com site in realtime. Changes to station information can take up to a day to appear, well it's now more than a day, but no playing information so far.
Is there a way to check off it's working?
Or is there something wrong with the webexport settings, your php file name is TuneIn API.php and is the map TuneIn, or have i remove the password and let it blank?
Greetings Nico.


[attachment deleted by admin]
Title: Re: TuneIn API Integration
Post by: AndyDeGroo on July 31, 2014, 07:57:42 AM
First, is your web server really listening on port 8080?
Second, check that have you inserted your API keys correctly?

Lets see what you get if you add another script for testing:
Code: [Select]
<?php
header
('Content-Type: text/plain');

$artist = isset($_REQUEST["artist"]) ? urlencode(stripcslashes($_POST["artist"])) : '';
$title = isset($_REQUEST["title"]) ? urlencode(stripcslashes($_POST["title"])) : '';

if(empty(
$artist) ||empty($title))
    exit(
'No data to send');

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

$response file_get_contents($url);
echo 
$response;
?>

Place it on your server as tunein-test.php, replace TuneIn values in $url and open http://localhost:8080/TuneIn/tunein-test.php?artist=Test&title=Test in your browser.


Title: Re: TuneIn API Integration
Post by: nchuijg on July 31, 2014, 10:13:36 AM
Andy,

This is what happening (see attachments), what do you mean with "First, is your web server really listening on port 8080" there's already a script running who reads the nowplaying.txt playlist and make php to html and a upload ftp to my site, it's running ok.
http://members.ziggo.nl/nchuijg/page1.htm
And the script from Marius from here http://www.radiodj.ro/community/index.php?topic=3440.0 was working ok as well.

What could be wrong?

Nico.

[attachment deleted by admin]
Title: Re: TuneIn API Integration
Post by: AndyDeGroo on July 31, 2014, 04:41:38 PM
Let me repeat myself (with emphasis):
Quote
Place it on your server as tunein-test.php, replace TuneIn values in $url and open http://localhost:8080/TuneIn/tunein-test.php?artist=Test&title=Test in your browser.
Title: Re: TuneIn API Integration
Post by: nchuijg on July 31, 2014, 05:30:25 PM
Let me repeat myself (with emphasis):
Andy,

This is what the browser tells me, like the txt file in the previous post.

Nico.

[attachment deleted by admin]
Title: Re: TuneIn API Integration
Post by: HMC on August 01, 2014, 04:49:46 AM
Andy,

This is what the browser tells me, like the txt file in the previous post.

Nico.

Something seems messed up on your localhost because it's not even parsing the html. You shouldn't see html tags.

Also if you are testing it in the browser it's going to be empty because you are checking the $_POST variable. You should use $_GET.

Code: [Select]
<?php
header
('Content-Type: text/plain');

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

if(empty(
$artist) ||empty($title))
    exit(
'No data to send');

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

$response file_get_contents($url);
echo 
$response;
?>


Also it looks like you are using an old version of Radiodj because newer versions allow you to choose your method. POST or GET. You should look into upgrading Radiodj also.  I believe the default is POST though even on that version. So the original script should work.
Title: Re: TuneIn API Integration
Post by: nchuijg on August 01, 2014, 10:27:27 PM
I think i found the problem, in the field custom data i set the string "artist=$artist$&title=$title$" but i think the webexporter do not generate artist and title.
I try it with the php script from Marius.
<?php

If ((isset($_POST["xpwd"])) && (isset($_POST["title"]))) {
   $xpwd= stripcslashes($_POST["xpwd"]);
   if ($xpwd== 'changeme') {
      $data = stripcslashes($_POST["title"]);

      $Handle = fopen("data.txt", 'w');
      fwrite($Handle, $data);
      fclose($Handle);
   }
} Else {
   echo "Go away!";
}

?>
When the custom data field is empty it generate in the data.txt file nowplaying information set by options, when i change in "artist=$artist$&title=$title$" than it generate nothing in the data.txt file, so i think this also happening with the TuneIn API script.
What could be the problem? is that string right?
From this topic; http://www.radiodj.ro/community/index.php?topic=3440.0
Has anyone got a clue?

Nico.
Title: Re: TuneIn API Integration
Post by: AndyDeGroo on August 01, 2014, 10:48:15 PM
Did you try what HMC suggested? I made a mistake in the script I posted and he corrected it.
If custom data field doesn't give results, try to leave it empty. Artist and title will still be sent to server.

Something seems messed up on your localhost because it's not even parsing the html. You shouldn't see html tags.
That is because of Content-type: text/plain header. I added that on purpose, to see what response TuneIn returns.

Try this in tunein-test.php and again, add your API details and open it in your browser to see what goes wrong:
Code: [Select]
<?php
header
('Content-Type: text/plain');

$artist = isset($_REQUEST["artist"]) ? urlencode(stripcslashes($_REQUEST["artist"])) : '';
$title = isset($_REQUEST["title"]) ? urlencode(stripcslashes($_REQUEST["title"])) : '';

// Save data for troubleshooting
file_put_contents'data.txt'print_r($_REQUESTtrue) );

if(empty(
$artist) ||empty($title))
    exit(
'No data to send');

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

$response file_get_contents($url);
echo 
$response;
?>
This will also save all received parameters to data.txt.
Title: Re: TuneIn API Integration
Post by: nchuijg on August 02, 2014, 09:36:33 AM
Hi Andy,
See for the results the attachment, and the data.txt shows
Array
(
    [xpwd] => Coen6210
    [title] => Hurricane Smith - Oh Babe What Would You Say [1972]
)
I understand that there is something wrong with HTTP request in the USB server, is there a solution for?
Nico.

[attachment deleted by admin]
Title: Re: TuneIn API Integration
Post by: AndyDeGroo on August 02, 2014, 11:30:33 AM
No, there is nothing wrong with HTTP request. Don't jump to conclusion if you don't know what you're talking about.
You get server error 500 from TunIn API, because you have replaced wrong bits of the url. You should have replaced whole "<id>", "<key>" and "<stationid>" with your values.

Your data.txt contains only combined title. You should try to use custom data field in RDJ and see what gets saved in data.txt. If custom data doesn't provide artist and title (it should), you'll have to parse artist from combined title.

To make script a bit more foolproof, here it is with API keys moved to the top:
Code: [Select]
<?php
// TuneIn API settings
$StationID "s######";         // TuneIn station ID
$PartnerID "########";     // TuneIn partner ID
$PartnerKey "_########"// TuneIn partner key

$artist = isset($_REQUEST["artist"]) ? urlencode(stripcslashes($_REQUEST["artist"])) : '';
$title = isset($_REQUEST["title"]) ? urlencode(stripcslashes($_REQUEST["title"])) : '';

// Save data for troubleshooting
file_put_contents'data.txt'print_r($_REQUESTtrue) );

if(empty(
$artist) ||empty($title))
    exit(
'No data to send');

$url "http://air.radiotime.com/Playing.ashx?partnerId={$PartnerID}&partnerKey={$PartnerKey}&id={$StationID}&title={$title}&artist={$artist}";

echo 
file_get_contents($url);
?>


Title: Re: TuneIn API Integration
Post by: Marius on August 02, 2014, 11:47:06 AM
OFF: I wonder how 10 lines of code need 2 pages and counting...  :D
Title: Re: TuneIn API Integration
Post by: HMC on August 02, 2014, 12:36:54 PM
OFF: I wonder how 10 lines of code need 2 pages and counting...  :D

Right? LOL

It really helps to learn basic PHP or customizing the site or what not will be difficult.

That is because of Content-type: text/plain header. I added that on purpose, to see what response TuneIn returns.


Yes duh I didn't pay attention to that for some reason.
Title: Re: TuneIn API Integration
Post by: nchuijg on August 02, 2014, 06:03:48 PM
Code: [Select]
[quote author=AndyDeGroo link=topic=5506.msg33030#msg33030 date=1406971833]
You get server error 500 from TunIn API, because you have replaced wrong bits of the url. You should have replaced whole "<id>", "<key>" and "<stationid>" with your values.
[/quote]

Andy,
First, there is nothing wrong with the id's and key from tunein, i copy/past them from the tunein e-mail, and checked them more then twice.
I find out that, the password in combination with a string in the custom data field in webexport, give's no artist and title information.
I let it blank, and with your new script now, it generate artist and title information in data.text.
I hope it works now, i have to wait a day or so to see of tunein wil update.
It could be that tunein sends me a wrong id and key.
Andy for now thank you so match, also HMC and Marius, and your moral support! and remember we are on page 3 of this subject, more to come?

Greetings Nico.
Title: Re: TuneIn API Integration
Post by: AndyDeGroo on August 02, 2014, 06:31:43 PM
First, there is nothing wrong with the id's and key from tunein, i copy/past them from the tunein e-mail, and checked them more then twice.
No, I didn't mean that your keys were wrong. It wasn't working because you had left "<" and ">" in the url.

To put it bluntly;
This was wrong:
Code: [Select]
http://air.radiotime.com/Playing.ashx?partnerId=<CXXXXXYi>&partnerKey=<_aXXXXhKNopL>&id=<s209409>

This is correct:
Code: [Select]
http://air.radiotime.com/Playing.ashx?partnerId=CXXXXXYi&partnerKey=_aXXXXhKNopL&id=s209409

Please pay more attention to instructions and try to understand what you are doing. I've learned many things by trial and error and you should too.
Title: Re: TuneIn API Integration
Post by: nchuijg on August 05, 2014, 09:59:33 PM
Andy,

I will let you know that the script is perfectly running, only when to many uploads in a short time go to tunein it blocks the gathering i think (time out) by two or more short items.
You have to consider that i dealing with RadioDJ just over two moths, and a shorter time with a php server, so there is a lot to learn, but for me its very abstract al those combination of chars in php.

Thank for your support once again, Nico.
Title: Re: TuneIn API Integration
Post by: Farinha on September 03, 2014, 07:38:36 PM
Please.  where i get partner ID  and Partnerkey?
Title: Re: TuneIn API Integration
Post by: packzap on September 04, 2014, 12:20:14 AM
You have to contact TuneIn directly. Tell them you are using RadioDJ as your primary automation transmission.
Title: Re: TuneIn API Integration
Post by: Farinha on September 04, 2014, 02:37:45 AM
Thanks Packzap
Title: Re: TuneIn API Integration
Post by: Farinha on September 06, 2014, 02:52:26 PM
Hy Guys.   Please help me. TUNEIN API doesnt work.   I did it like MariusĀ“s post in NOW PLAYING INFO.  I have PartnerId , key, stationid.
I eliminate "<>".  Whats wrong?     

Radiodj   1.7.3.0
Title: Re: TuneIn API Integration
Post by: TORPEDA on September 28, 2014, 09:15:58 PM
Farinha,
I've got two stations running on RadioDJ and both are feeling fine with TuneIn API. Please, check again if you did everything as it shown on Marius's post. Eliminate "<>". Set method as GET and check ENABLE. It could take some time for Api to start working. A could of hours at least. Good luck!
Title: Re: TuneIn API Integration
Post by: Chrispy on October 08, 2014, 11:58:10 PM
I'm trying to send my TuneIn data only if the track type is '0'.  I don't knwo how to do PHP, can someone tell me where I'm going wrong (I've currently got a mash of a couple of other peoples scripts and it doesn't work properly)?

I'd also like to send the 'commercial=true' flag to TuneIn when the track type is anything other than '0'.  Can anyone help?

This is what I have so far (the data.txt file works just fine, everything after that fails).

I should point out that I replace the key, partner and station IDs with mine when using the script.

Thanks.

Code: [Select]
<?php
If ((isset($_POST["xpwd"])) && (isset($_POST["title"]))) {
$xpwdstripcslashes($_POST["xpwd"]);
if ($xpwd== 'mypasswordishere') {
$data .= stripcslashes($_POST["artist"]);
$data .= " - ";
$data .= stripcslashes($_POST["title"]);
$data .= " - ";
$data .= stripcslashes($_POST["track-type"]);
$Handle fopen("data.txt"'a');
fwrite($Handle$data."\n");
fclose($Handle);
        if (
track-type== '0')
                
$url "http://air.radiotime.com/Playing.ashx?partnerId=<id>&partnerKey=<key>&id=<stationid>&title=".$title."&artist=".$artist;
}
} Else {
echo "Access Denied";
}
?>
Title: Re: TuneIn API Integration
Post by: AndyDeGroo on October 09, 2014, 12:53:53 AM
Did you run AutoUpdate.exe to get latest files after this post by Marius (http://www.radiodj.ro/community/index.php?topic=5986.msg34820#msg34820)? Marius has fixed the $track-type$ issue I reported after releasing version 1.7.4.

You didn't mention what you have in your custom data field. Did you add "&track-type=$track-type$"? Are you actually sending the xpwd parameter? Note that if you type anything in "Custom Data", the password filed is ignored and you have to add xpwd=Pa$$w00rd to custom data.
Your script just creates the url and does nothing to make actual request. Where do you get title and artist variables?

Ok, your script wouldn't work anyway...

Here is a script that should do what you want:
Code: [Select]
<?php
define
('RDJ_PASSWORD''type your web export password here'); // RadioDJ Web Export password
$partnerId "XXXXX"// TuneIn API partner ID
$partnerKey "XXXXX"// TuneIn API partner key
$stationId "XXXXX"// TuneIn API station ID

ini_set('error_log''php_error.log');
ini_set('log_errors''on');
error_reporting(E_ERROR E_WARNING E_PARSE);

file_put_contents('data.txt'print_r($_POSTtrue)); // comment out this line after debugging

if ( isset($_POST["xpwd"]) && stripcslashes($_POST["xpwd"]) == RDJ_PASSWORD && isset($_POST["title"]) ) {    
    
$artisturlencode(stripcslashes($_POST["artist"]));
    
$title urlencode(stripcslashes($_POST["title"]));

    
$track_type = isset($_POST['track-type'])? (int)$_POST['track-type'] : -1;
    
$commercial = ($track_type === 0) ? 'false' 'true'// Check if track-type is exactly 0 (for Song) and set commercial flag accordingly

    
$url "http://air.radiotime.com/Playing.ashx?partnerId=$partnerId&partnerKey=$partnerKey&id=$stationId&title=".$title."&artist=".$artist."&commercial=$commercial";
    
$response file_get_contents($url);
    echo 
$response;

    
//file_put_contents('last_response.txt', date('[Y-m-d H:i:s]')."\n".$response); // for debugging

} else {
    echo 
"Access Denied";
}
?>


Just fill in the variables and RDJ_PASSWORD define at the top and it should work. I say "should" because I didn't test it.
This script assumes that your custom data contains following string:
Code: [Select]
xpwd=Pa$$w00rd&title=$title$&artist=$artist$&track-type=$track-type$

Please note that track-type variable must be provided and it must be a number or it will send everything as commercial=true.
Title: Re: TuneIn API Integration
Post by: Chrispy on October 09, 2014, 08:47:46 AM
That's amazing. Thank you.  I'll test it today.
Oh, and I am updated to 1.7.5 :)
Title: Re: TuneIn API Integration
Post by: Chrispy on October 09, 2014, 02:31:33 PM
I've had it running this morning and I got a PHP error to start with:
Code: [Select]
[09-Oct-2014 12:28:57 UTC] PHP Warning:  file_get_contents(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in tunein.php on line 21
[09-Oct-2014 12:28:57 UTC] PHP Warning:  file_get_contents(http://air.radiotime.com/Playing.ashx?partnerId=xxxxxxxx&amp;partnerKey=xxxxxxxx&amp;id=sxxxxxx&amp;title=If+It+Makes+You+Happy&amp;artist=Sheryl+Crow&amp;commercial=false): failed to open stream: no suitable wrapper could be found in tunein.php on line 21
I commented out the response section but I don't know if it is working or not!  My now playing info hasn't started appearing on TuneIn yet (we're here: http://tunein.com/radio/Beyond-Radio-s195739)!  No PHP errors though.

I'm not sure my partner key is being sent properly as it is missing some characters in the PHP error log and it contains a '$'.

I ended up using:
Code: [Select]
<?php
define
('RDJ_PASSWORD''password'); // RadioDJ Web Export password
$partnerId "xxxxxx"// TuneIn API partner ID
$partnerKey "xxxxxxxxxxxx"// TuneIn API partner key
$stationId "sxxxxxx"// TuneIn API station ID

ini_set('error_log''php_error.log');
ini_set('log_errors''on');
error_reporting(E_ERROR E_WARNING E_PARSE);

file_put_contents('data.txt'print_r($_POSTtrue)); // comment out this line after debugging

if ( isset($_POST["xpwd"]) && stripcslashes($_POST["xpwd"]) == RDJ_PASSWORD && isset($_POST["title"]) ) {    
    
$artisturlencode(stripcslashes($_POST["artist"]));
    
$title urlencode(stripcslashes($_POST["title"]));

    
$track_type = isset($_POST['track-type'])? (int)$_POST['track-type'] : -1;
    
$commercial = ($track_type === 0) ? 'false' 'true'// Check if track-type is exactly 0 (for Song) and set commercial flag accordingly

    
$url "http://air.radiotime.com/Playing.ashx?partnerId=$partnerId&partnerKey=$partnerKey&id=$stationId&title=".$title."&artist=".$artist."&commercial=$commercial";
/*  $response = file_get_contents($url);
    echo $response;

    //file_put_contents('last_response.txt', date('[Y-m-d H:i:s]')."\n".$response); // for debugging */

} else {
    echo 
"Access Denied";
}
?>

Title: Re: TuneIn API Integration
Post by: AndyDeGroo on October 09, 2014, 03:08:47 PM
You've commented out the part which does the actual sending, hence nothing is being sent. The issue is as stated in the first error: "http:// wrapper is disabled in the server configuration by allow_url_fopen=0".

There are two options:
Easiest: If you control the server, enable allow_url_fopen=on or ask if your hosting provider can do it for you.
Harder: Rewrite the script to use curl, which I've already done for you below...

Here I've added a function to use curl when allow_url_fopen is disabled:
Code: [Select]
<?php
define
('RDJ_PASSWORD''type your web export password here'); // RadioDJ Web Export password
$partnerId "XXXXX"// TuneIn API partner ID
$partnerKey "XXXXX"// TuneIn API partner key
$stationId "XXXXX"// TuneIn API station ID

//file_put_contents('data.txt', print_r($_POST, true)); // Uncomment this line for debugging

function http_request($url) {
    
$response null;
    if( 
ini_get('allow_url_fopen') ) {
        
$response file_get_contents($url);
    } elseif(
function_exists('curl_init')) {
        
$curl curl_init($url);
        
curl_setopt($curlCURLOPT_RETURNTRANSFER1);
        
$response curl_exec($curl);
        
curl_close($curl);
    } else {
        
trigger_error("Cannot fetch resource because allow_url_fopen is disabled and cURL is not available"E_USER_ERROR);
    }
    return 
$response;
}

if ( isset(
$_POST["xpwd"]) && stripcslashes($_POST["xpwd"]) == RDJ_PASSWORD && isset($_POST["title"]) ) {   
    
$artiststripcslashes($_POST["artist"]);
    
$title stripcslashes($_POST["title"]);

    
$track_type = isset($_POST['track-type'])? (int)$_POST['track-type'] : -1;
    
$commercial = ($track_type === 0) ? 'false' 'true'// Check if track-type is exactlt 0 (for Song) and set commercial flag accordingly
    
$url "http://air.radiotime.com/Playing.ashx?partnerId=$partnerId&partnerKey=$partnerKey&id=$stationId&title=".$title."&artist=".$artist."&commercial=$commercial";
    
$response http_request($url);
    echo 
$response;

    
//file_put_contents('last_response.txt', date('[Y-m-d H:i:s]')."\n".$response); // for debugging

} else {
    echo 
"Access Denied";
}
?>

The script will fail and trigger an error if allow_url_fopen=0 and if PHP cURL extension is not enabled. If cURL is not available on your web server and you are paying for hosting services, you should consider changing your provider.

Obligatory note: Script was not tested and might fail miserably. Although I try my best to write working scripts without testing.
Title: Re: TuneIn API Integration
Post by: Chrispy on October 09, 2014, 04:26:44 PM
Brilliant. :)

The return from 'last_response.txt' is:
Code: [Select]
[2014-10-09 14:22:05]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">

<HTML><HEAD><TITLE>Bad Request</TITLE>

<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>

<BODY><h2>Bad Request</h2>

<hr><p>HTTP Error 400. The request is badly formed.</p>

</BODY></HTML>


I still suspect that my partner key isn't being sent correctly as it contains a '$' sign.
Title: Re: TuneIn API Integration
Post by: AndyDeGroo on October 09, 2014, 09:14:39 PM
Did you paste your credentials at the beginning of file? For example:
Code: [Select]
<?php
$partnerId 
"s2094XX"// TuneIn API partner ID
$partnerKey "CXaZVxxx"// TuneIn API partner key
$stationId "_aBy76XXXopL"// TuneIn API station ID
?>


I suspect that you tried to modify the $url string directly, which you don't touch at all.
Title: Re: TuneIn API Integration
Post by: Chrispy on October 10, 2014, 12:25:43 AM
Yes, I've pasted it below (with a few bits x'd out :P). Although the partner key has a dollar sign which I think is being translated as code.  I tried changing the speech marks (") to apostrophes (') but it didn't make a difference.

Code: [Select]
$partnerId = 'z9bVxxxx'; // TuneIn API partner ID
$partnerKey = 'xxxxxxs8j$qe'; // TuneIn API partner key
$stationId = 's195xxx'; // TuneIn API station ID
Title: Re: TuneIn API Integration
Post by: rogiermaas on October 10, 2014, 01:12:54 AM
I didn't really follow this whole thread, but I can say this:

PHP has a few characters it uses for controlling variables. Things like ", $ and \ for example, won't be parsed correctly if their not 'escaped' right.

Example: when you want to have a variable $myvar with contents: Hello, this script runs on Windows in C:\scripts\ and cost me $1 to make!
you would think this is what you'd want to do:

$myvar = "Hello, this script runs on Windows in C:\scripts\ and cost me $1 to make!";

This goes wrong, because of the special characters in this var. PHP uses $ for variables, so it thinks it should replace the $1 for the contents of '$1' which doesn't exist. Also, the Windows path contains backslashes, used by PHP to literally use the character next to it.

If you want to use special chars in your PHP script (in your case the dollar-sign in your key might be a problem) you could 'escape' the dollar sign, telling PHP to literally use the dollar-sign and not process it, looking up contents of a variable.

If your key was abc$ABC, you could use abc\$ABC. By using the escape-char (\), you're telling PHP to just work with the next char. Also, when wanting to just use a backslash, use \\.

"A friend of mine told me he uses "RadioDJ"" would result in an error. Using: "A friend of mine told me he uses \"RadioDJ\"" would be correctly processed.

Hope this helps!

- Rogier
Title: Re: TuneIn API Integration
Post by: AndyDeGroo on October 10, 2014, 03:24:09 PM
Yes, I've pasted it below (with a few bits x'd out :P ). Although the partner key has a dollar sign which I think is being translated as code.  I tried changing the speech marks (") to apostrophes (') but it didn't make a difference.

In addition to Rogier's post: If you have to use a dollar sign in a string, use single quotes (') to enclose the string: $variable = 'This $variable is not treated as variable' or escape using a backslash if the string is enclosed in double quotes ("): $variable = "This is \$notavariable" as Rogier suggests. So your change to single quotes (') should have worked as expected. You should debug the $url variable by adding it to the content to be written to file:
Code: [Select]
<?php
file_put_contents
('last_response.txt'date('[Y-m-d H:i:s]')."\nURL: ".$url."\n".$response); // for debugging
?>

And then check last_response.txt file.

You can play around in another script to understand how basic PHP syntax works:
Code: [Select]
<?php
$foo 
"eggs";
$bar "easter";

echo 
"<pre>"// HTML pre tag, so we can use newlines instead of <br />

echo $bar.' '.$foo PHP_EOL// Outputs: "easter eggs"

echo "$bar $fooPHP_EOL// Same as above 

echo '$bar $foo' PHP_EOL// Outputs: "$bar $foo" because variables in single-quote-enclosed strings are not evaluated

echo "\$bar \$foo" PHP_EOL// Same as above 

$foobar "$foo $bar"// $foobar becomes "easter eggs"

echo '$foobar is '.$foobar PHP_EOL;

$foobar '$foo $bar'// $foobar gets set to "$foo $bar"

echo '$foobar is '.$foobar PHP_EOL;

echo 
"</pre>"
?>



Title: Re: TuneIn API Integration
Post by: elsilva0 on October 11, 2014, 02:35:18 AM
Wut does this implement or tunein agreement do?
Title: Re: TuneIn API Integration
Post by: AndyDeGroo on October 11, 2014, 04:34:22 AM
Wut does this implement or tunein agreement do?

It gives you ability to show what's playing to your TuneIn listeners. Have you used TuneIn (http://tunein.com/)? They have a web app and smartphone apps for listening to radio stations that are registered on the service. It might give you more listeners from around the world and make yous station easier to discover.
Title: Re: TuneIn API Integration
Post by: elsilva0 on October 11, 2014, 06:07:11 AM
My station is on tunein, but i didnt understand why do i have to have tunein api integration, if my station is on tune in wut would change ? sorry if it was a stupid question, i not sure bout tunein api   :bash:
Title: Re: TuneIn API Integration
Post by: AndyDeGroo on October 11, 2014, 06:52:47 AM
Compare your TuneIn page with this one (http://tunein.com/radio/Radio-H2O-s209409/). You may see that there is a list of played songs and when you click "expand", there is description and images of an artist.
Title: Re: TuneIn API Integration
Post by: HMC on October 13, 2014, 12:23:04 AM
My station is on tunein, but i didnt understand why do i have to have tunein api integration, if my station is on tune in wut would change ? sorry if it was a stupid question, i not sure bout tunein api   :bash:
Compare your TuneIn page with this one (http://tunein.com/radio/Radio-H2O-s209409/). You may see that there is a list of played songs and when you click "expand", there is description and images of an artist.

Note that you can't just implement this API without getting TuneIn's permission and they have to set your account up to work with it.  I use the API and it makes a difference because people can see the current song playing on my station and recently played songs without having to be on my own site.

http://tunein.com/broadcasters/api/ (http://tunein.com/broadcasters/api/)

Title: Re: TuneIn API Integration
Post by: AndyDeGroo on October 13, 2014, 08:49:26 AM
There is one catch with TuneIn - anyone can edit your station's details and set stream URLs. Recently someone, maybe competitor, had updated stream URLs of our station to empty values, effectively making the TuneIn profile useless. I updated the streams and sent a complaint. I also suggested to add broadcaster authentication for station edits and to make Air API registration easier, but I haven't heard back from them.
Title: Re: TuneIn API Integration
Post by: HMC on October 13, 2014, 06:01:35 PM
There is one catch with TuneIn - anyone can edit your station's details and set stream URLs. Recently someone, maybe competitor, had updated stream URLs of our station to empty values, effectively making the TuneIn profile useless. I updated the streams and sent a complaint. I also suggested to add broadcaster authentication for station edits and to make Air API registration easier, but I haven't heard back from them.

Yes, I always thought that was the most ridiculous setup.  It makes no sense that they would accept edits from someone that doesn't own the station essentially destroying your station. It should be a profile that only you can control just like any other profile. Maybe if enough people complain about this very clumsy setup they will change it.
Title: Re: TuneIn API Integration
Post by: Chrispy on October 14, 2014, 12:12:38 AM
Thanks so much for your help AndyDeGroo and rogiermaas. I will certainly try to learn more about the syntax from your examples.  I will keep you up to date with any advances with this.  I don't have much time to play with it this week but will be doing so soon.
Title: Re: TuneIn API Integration
Post by: elsilva0 on November 10, 2014, 11:39:07 PM
Where is the link to get the Tune in API?
Title: Re: TuneIn API Integration
Post by: AndyDeGroo on November 10, 2014, 11:54:58 PM
Where is the link to get the Tune in API?
Did you read the TuneIn API documentation (http://tunein.com/broadcasters/api/)? You have to request API keys by sending an email.
Title: Re: TuneIn API Integration
Post by: elsilva0 on November 11, 2014, 12:28:37 AM
Did you read the TuneIn API documentation (http://tunein.com/broadcasters/api/)? You have to request API keys by sending an email.

Yeah, i 've seen the tune in APIdocumentation , ive sent the email.

I got other question looking this station:
(http://prntscr.com/554jp4)
http://prntscr.com/554jp4 (http://prntscr.com/554jp4)
Title: Re: TuneIn API Integration
Post by: laurent-CETARadio on December 17, 2014, 05:56:34 PM
Hello, I would like to contribute to this script.
Our radio station is listed on radioline and the specification need an xml file to submit to their staff.

My little contribution...

Code: [Select]
<?php
define
('RDJ_PASSWORD''xxxxxx'); // RadioDJ Web Export password
$partnerId "xxxxxx"// TuneIn API partner ID
$partnerKey "xxxxxx"// TuneIn API partner key
$stationId "xXXXXXX"// TuneIn API station ID
$stationName "XXXX Radio"// Station Name
$timezone "Europe/Paris"// Time Zone Station
$stationurl "http://www.xxx.yy"// Station Url 

ini_set('error_log''php_error.log');
ini_set('log_errors''on');
error_reporting(E_ERROR E_WARNING E_PARSE);

// file_put_contents('data.txt', print_r($_POST, true)); // comment out this line after debugging

if ( isset($_POST["xpwd"]) && stripcslashes($_POST["xpwd"]) == RDJ_PASSWORD && isset($_POST["title"]) ) {    
    
$artiststripcslashes($_POST["artist"]);
    
$title stripcslashes($_POST["title"]);
    
$start stripcslashes($_POST["start"]);
    
$durations stripcslashes($_POST["durations"]);
    
$artist_tuneinurlencode(stripcslashes($_POST["artist"]));
    
$title_tunein urlencode(stripcslashes($_POST["title"]));
    
$track_type = isset($_POST['track-type'])? (int)$_POST['track-type'] : -1;
    
$commercial = ($track_type === 0) ? 'false' 'true'// Check if track-type is exactly 0 (for Song) and set commercial flag accordingly

    
$url "http://air.radiotime.com/Playing.ashx?partnerId=$partnerId&partnerKey=$partnerKey&id=$stationId&title=".$title_tunein."&artist=".$artist_tunein."&commercial=$commercial";
    
$response file_get_contents($url);
    echo 
$response;

    
// file_put_contents('last_response.txt', date('[Y-m-d H:i:s]')."\n".$response); // for debugging

// for Radioline XML : for further informations, consult http://cms.radioline.co/XML-file-structure-specifications-for-Music-track-metadata-and-Electronic-Program-Guide-_EPG_.pdf
$xw = new xmlWriter;
$xw->openMemory();
$xw->setIndent(true);
$xw->setIndentString("\t");

$xw->startDocument('1.0''utf-8');
$xw->startElement('rol_notification');
$xw->writeElement('name',$stationName);
$xw->writeElement('timeZone',$timezone);
$xw->writeElement('url',$stationurl);
$xw->startElement('onair');
$xw->writeElement('start',$start);
$xw->writeElement('duration',$durations);
$xw->writeElement('title',$title);
$xw->writeElement('artist',$artist);
$music_type = ($track_type === 0) ? 'S' 'A'// S for Music, A for Advertisement
$xw->writeElement('music',$music_type);
// End onair element
$xw->endElement();
// End rol_notification element
$xw->endElement();
file_put_contents('radioline.xml'$xw->outputMemory(true));

} else {
    echo 
"Access Denied";
}
?>

I changed the variables name "artist" and "title" for tune in, due to urlencode function.
Title: Re: TuneIn API Integration
Post by: AndyDeGroo on December 18, 2014, 06:40:00 PM
Hi Laurent,

Great to see someone contributing to this script.
However, I'm not familiar with radioline and have a question: What do you do with the generated xml file? Is it fetched by them or do you submit it to their service?
Title: Re: TuneIn API Integration
Post by: laurent-CETARadio on December 18, 2014, 07:00:43 PM
Good Evening Andy
You have to create an account to cms.radioline.co. You can refer your radio station, podcast...
once it's done, you submit the xml to editorial@radioline.co (from my memory)
all the specs are in this pdf: http://cms.radioline.co/XML-file-structure-specifications-for-Music-track-metadata-and-Electronic-Program-Guide-_EPG_.pdf

Cheers!
Title: Re: TuneIn API Integration
Post by: 001FM on January 04, 2015, 12:37:56 PM
Hello,

thanks to laurent-CETARadio and AndyDeGroo for the scripts!

I'm using the script above and i'm facing a problem. I have two radio stations. First one is working fine, but my second one has a partnerID and a partnerKey with special characters. I'm getting a 403 error page everytime in the last_response.txt.
My first station has no special characters in it and its working perfect!

My partnerID is looking like this: Xx*1xXXX
PartnerKey looking like this: _$X1x11x1xX_

It seems that the script has problems with the special characters. Can anyone help me to get it working? When i'm using the normal mode (like Marius said) it works.

Thanks!
Title: Re: TuneIn API Integration
Post by: 001FM on January 06, 2015, 01:09:35 AM
No one there, that could help me?  :o :(
Title: Re: TuneIn API Integration
Post by: joshuatree44 on January 15, 2015, 05:09:40 AM
I am trying to follow what is going on here, but I am completely lost. I am looking over the tunin.com page and I have to email their support, but I have no idea what to email them. I wish they had something setup for radiodj on that page too. I mean this is very confusing. I also have copied the above php and placed it into a new page on wordpress site. However how does the radiodj stuff get to my site from the server here? I wish there was a simple setup per say on this.
Title: Re: TuneIn API Integration
Post by: Chaos Radio! on January 15, 2015, 03:37:50 PM
I am trying to follow what is going on here, but I am completely lost. I am looking over the tunin.com page and I have to email their support, but I have no idea what to email them. I wish they had something setup for radiodj on that page too. I mean this is very confusing. I also have copied the above php and placed it into a new page on wordpress site. However how does the radiodj stuff get to my site from the server here? I wish there was a simple setup per say on this.

Hopefully this might help?
If you are already set up to broadcast on Tunein, you need to email them and ask for your stations API which will be the  Partner ID STATION ID and KEY you will need to send info to Tunein.

Make sure in your email to give them your station ID. which should be on the top of the page your station has at Tunein.

Once you have received the info from Tunein then follow the post and instructions from Marius below.

Open Now Playing info (plugin) 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.

Bottom of form:
Set method to GET and check the Enable check-box.

Should be all set, your streamed content will show up on tunein.
Title: Re: TuneIn API Integration
Post by: joshuatree44 on January 19, 2015, 07:13:20 PM
Thank you for your help. I am going to email them now. I am just confused on what the heck all that stuff is and what to do and the like. I mean it just sounds all Greek to me. Now how will I display this stuff on my website or is that not what this is for? Also, I am wondering about the sam-song.info stuff as well. Is there a way to have that going as well????
Title: Re: TuneIn API Integration
Post by: yatusabes on January 21, 2015, 04:31:02 PM
I got my Partner ID STATION ID and KEY from TuneIn. I write the information in the Web Export like Marius says.

RadioDJ starts sending the info to TuneIn. But not only sends the name of the songs, it sends too the name of commercials, promos, news bulletin, etc...

Is there any way that RadioDj only sends the song's information?
Title: Re: TuneIn API Integration
Post by: joshuatree44 on January 21, 2015, 08:36:27 PM
I think your stuck with it all going to there. It is not a big deal to be honest. i would however like to send it to tunein but also like I had it to twitter and the like. I am wondering how I will use sam-song.info when I have the stuff going to tunein. Would I have to copy and create a second instance of the playing info plugin?
Title: Re: TuneIn API Integration
Post by: joshuatree44 on January 23, 2015, 01:01:42 AM
How long does TuneIn take to send you the items? I have been waiting over a month or so. They must be really hard to get or something.
Title: Re: TuneIn API Integration
Post by: Chaos Radio! on January 23, 2015, 04:12:05 AM
How long does TuneIn take to send you the items? I have been waiting over a month or so. They must be really hard to get or something.

Ha....the fun game of TuneIn support. they have two yes two people handling support as far as I can tell.

The best thing to do is keep emailing them daily.
Title: Re: TuneIn API Integration
Post by: joshuatree44 on January 29, 2015, 10:31:23 PM
got my digits today. I noticed that if you email the broadcast-support@tunein.com it gets faster to them than normal support email. I am loving the stuff displaying. Now I have to try and get the sam-song.info working prob with a copy of the plugin? update, nope it does not work with a copy. That stinks. It is either one or the other. Bummer. Also, I noticed that TuneIn.com API does not show cover art for everything. Which is odd. But for the most part it does what I want it to do. It seems like it gets confused.
Title: Re: TuneIn API Integration
Post by: joshuatree44 on February 05, 2015, 06:33:29 AM
This setup does not work 100% with TuneIn. I am not sure what I have wrong but it is only working 25% of the time.
Title: Re: TuneIn API Integration
Post by: Nitrofish on February 14, 2015, 03:17:07 AM
I think your stuck with it all going to there. It is not a big deal to be honest. i would however like to send it to tunein but also like I had it to twitter and the like. I am wondering how I will use sam-song.info when I have the stuff going to tunein. Would I have to copy and create a second instance of the playing info plugin?

I see that others are using PHP to send only songs. Is there a way to do it without using PHP? It seems that when my sweepers play, it messes up TuneIn's ability to display the correct info. SAM uses this PAL script and it works flawlessly:

Code: [Select]
{
Script to submit song info to the TuneIn AIR API (http://tunein.com/broadcasters/api/).
The stationId, partnerId and partnerKey values need to be set for this to work.
}

const STATION_ID = 'XXX990';
const PARTNER_ID = 'XXXXXXnt';
const PARTNER_KEY = 'XXXXXXXXxSKq';

var player : TPlayer;
var song : TSongInfo;
var baseUrl: String;

FUNCTION urlEncode(s: String): String; forward;
PROCEDURE update(stationId, partnerId, partnerKey, artist, title : String); forward;

{Main}
PAL.Loop := true;

PAL.WaitForPlayCount(1);
player := ActivePlayer;
IF ( player <> NIL ) THEN
BEGIN
IF ( player.Duration > 45000 ) THEN
BEGIN
song := player.GetSongInfo;
IF ( song <> NIL ) THEN
BEGIN
update(STATION_ID, PARTNER_ID, PARTNER_KEY, song['artist'],song['title']);
song.Free;
END;
END;
END;

FUNCTION urlEncode(s: String): String;
BEGIN
var index : integer;
var intVal : integer;
result := '';

PAL.LockExecution;

IF (Length(s)) > 0 THEN
BEGIN
FOR index := 1 TO length(s) DO
BEGIN
intVal := Ord(s[index]);
IF ((intVal > 47) AND (intVal < 58)) OR ((intVal > 64) AND (intVal < 91)) OR ((intVal > 96) AND (intVal < 123))  THEN
BEGIN
result := result + (s[index])
END
ELSE
BEGIN
IF ( intVal < 128 ) THEN
BEGIN
result := result + '%' + IntToHex(intVal, 2);
END
ELSE IF ( intVal < 2048 ) THEN
BEGIN
result := result + '%' + IntToHex( $C0 or Trunc( intVal / 64 ), 2 ) + '%' + IntToHex( $BF and intVal, 2 );
END
ELSE
BEGIN
// not yet supported
END;
END;
END;
END;
PAL.UnlockExecution;
END;

PROCEDURE update(stationId, partnerId, partnerKey, artist, title : String);
BEGIN
var req : String;
req := 'http://air.radiotime.com/Playing.ashx?id=' + stationId
+ '&partnerId=' + urlEncode(partnerId)
+ '&partnerKey=' + urlEncode(partnerKey)
+ '&title=' + urlEncode(title)
+ '&artist=' + urlEncode(artist);

WebToStr(req);
END;

I too am using a Twitter script (sam-song.info) on SAM that sends artist, song title to Twitter. Is anyone working on a plugin for RDJ that can post to Artist and Song Title to Twitter, and/or Facebook?
Title: Re: TuneIn API Integration
Post by: joshuatree44 on February 14, 2015, 04:09:57 AM
you are right that the tunein.com gets goofed by Voice Tracks or sweepers. I dont get how to change the script to just send the song. I just wish I could get everything working nicely.
Title: Re: TuneIn API Integration
Post by: AndyDeGroo on March 27, 2015, 02:52:39 AM
you are right that the tunein.com gets goofed by Voice Tracks or sweepers. I dont get how to change the script to just send the song. I just wish I could get everything working nicely.

That was already added to the script and works since Marius added $track-type$ variable to NowPlaying plugin. See this post (http://www.radiodj.ro/community/index.php?topic=5506.msg34848#msg34848).
Title: Re: TuneIn API Integration
Post by: joshuatree44 on March 27, 2015, 05:40:56 AM
OK that is great, however where and or what do we do to change it? I am looking at the link you have Andy but no idea what I am supposed to do.

That was already added to the script and works since Marius added $track-type$ variable to NowPlaying plugin. See this post (http://www.radiodj.ro/community/index.php?topic=5506.msg34848#msg34848).
Title: Re: TuneIn API Integration
Post by: AndyDeGroo on March 28, 2015, 07:52:38 AM
OK that is great, however where and or what do we do to change it? I am looking at the link you have Andy but no idea what I am supposed to do.

That is a PHP script to be used with web export feature of Playing info plugin.
The script sends commercial=true variable to TuneIn API if track-type variable from RadioDJ is not zero. You can modify the script to send updates just for track types you choose.

Updated script with filtering of track types and some other improvements:
Code: [Select]
<?php

/**
 * You have to supply track-type variable in custom data field of RadioDJ web export.
 * The custom data field should contain at least:
 * xpwd=WEB_EXPORT_PASSWORD&track-type=$track-type$&artist=$artist$&title=$title$
 * You can expand upon this code using the http_request() function to interact with other services, like the sam-song.info by Mastacheatah.
 */

define('RDJ_PASSWORD''WEB_EXPORT_PASSWORD'); // RadioDJ Web Export password
$partnerId "XXXXX"// TuneIn API partner ID
$partnerKey "XXXXX"// TuneIn API partner key
$stationId "XXXXX"// TuneIn API station ID

// Track types to send updates for
// Comment out/uncomment as needed
$allowed_track_types = array(
0,// Music
//1,// Jingle
//2,// Sweeper
//3,// Voiceover
//4,// Commercial
5,// InternetStream
//6,// Other
7,// VDF
8,// Podcast
9,// Request ???
10,// News
//11,// PlaylistEvent
12,// FileByDate
13,// NewestFromFolder
//14// Teaser
);

// Don't send update if track type not one of allowed
$skip_update_if_not_allowed true;

//file_put_contents('POST_data.txt', print_r($_POST, true)); // Uncomment this line for debugging

// Fake user agent string
ini_set('user_agent''Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9');

function 
http_request$url ) {
$response null;
if(function_exists('curl_init')) {
$curl curl_init($url);
curl_setopt($curlCURLOPT_RETURNTRANSFER1);
curl_setopt($curlCURLOPT_USERAGENTini_get('user_agent')); // just to be sure to use the php.ini setting
$response curl_exec($curl);
curl_close($curl);
} elseif( ini_get('allow_url_fopen') ) {
$response file_get_contents($url);
} else {
trigger_error("Cannot fetch resource because allow_url_fopen is disabled and cURL is not available"E_USER_ERROR);
}
return $response;
}

/**
 * Wrapper function for $_POST variables
 * @param string $var Key to get from $_POST array
 * @param mixed $default Default value to return if key not found
 * @return mixed Value of $_POST array if found, $default otherwise
 */
function post_var$var$default null ) {
return isset($_POST[$var]) ? $_POST[$var] : $default;
}

if ( 
post_var('xpwd') == RDJ_PASSWORD ) {

$track_type post_var('track-type', -1);

if($skip_update_if_not_allowed && !in_array($track_type$allowed_track_types)){
exit('Track type not allowed: '.$track_type);
}

$artist stripcslashes(trim(post_var('artist','')));
$title stripcslashes(trim(post_var('title','')));

if(empty($artist) || empty($title)){
exit('Missing song artist/title');
}

$params = array(
'partnerId' => $partnerId,
'partnerKey'=> $partnerKey,
'id' => $stationId,
'artist' => $artist,
'title' => $title
);
if( !in_array($track_type$allowed_track_types) ) {
$params['commercial'] = 'true';
}
$params http_build_query($params);

$url "http://air.radiotime.com/Playing.ashx?".$params;

$response http_request($url);
echo $response;

//file_put_contents('last_response.txt', date('[Y-m-d H:i:s]')."\nURL:".$url."\n".$response); // for debugging

} else {
echo "Access Denied";
}
?>

Title: Re: TuneIn API Integration
Post by: joshuatree44 on March 28, 2015, 03:05:21 PM
OK that is fine and all, but where am I putting this script? Also, I am running RDJ off my windows machine so not sure where I would put it? I would love to have it work as you say but you dont say where I put this script.
Title: Re: TuneIn API Integration
Post by: AndyDeGroo on March 29, 2015, 06:58:28 AM
OK that is fine and all, but where am I putting this script? Also, I am running RDJ off my windows machine so not sure where I would put it? I would love to have it work as you say but you dont say where I put this script.

Well, PHP usually runs on a web server.  You could place it on your web site or run it locally on same PC as RadioDJ. PHP has its own built-in web server so you don't need Apache or nginx web server to run the script. Running PHP web server is as easy as running a command in command prompt:
Code: [Select]
php.exe -S localhost:80 -t C:\path_to_webroot\After that you can access the server on http://localhost:80/. For convenience you could use nssm.exe (Non-Sucking Service Manager) to run PHP as a Windows service so you don't have to open cmd window and run it manually.

To make use of the script:

It would be nice if now playing plugin allowed to add multiple HTTP endpoints. I've been thinking about creating a separate plugin which could do that but haven't had enough free time. I guess I'm not motivated enough, because I can do it in PHP. :)
Title: Re: TuneIn API Integration
Post by: joshuatree44 on March 29, 2015, 07:13:12 PM
OK I am going to try it again. It did not work for me when I tried it before. Lets hope it works fine in WP since I dont like to do anything outside in HTML/PHP but oh well.

Access Denied is what I got when I followed what you said to do. So not sure what I flubbed but I changed it all like it said.
http://www.asylum.rocks/radiodj/web-export.php (http://www.asylum.rocks/radiodj/web-export.php)
Title: Re: TuneIn API Integration
Post by: joshuatree44 on March 29, 2015, 10:25:54 PM
So am I to take it the page I created just sits there and runs on the server? If so that is fine since I see TuneIn is working nicely now. Just wish I could somehow put the CD covers and the like into a page on my site. But I can always want but never get unless I figure out something on my own too. BTW, Thanks Andy for your help again. I will pay your bill some day!  ;D

Just a small note, when you put the file on your server, at least for me, I used FileZilla. It did not work with the uploading it via cPanel file manager. Just a small note. Also I changed the file permissions to 755 just for habit. Not sure it needs those but it is working here just fine.
Title: Re: TuneIn API Integration
Post by: AndyDeGroo on March 30, 2015, 03:17:05 AM
Well, to show album art and other info on your page, the script would have to do more. The best way I've figure is to save info in nowplaying.json file and then fetch that file using JavaScript+AJAX. You would also have to fetch album art from somewhere. It could be your web server but that requires uploading album art from RadioDJ and keeping those files in sync. Another option is to query last.fm using PHP and then use their images.

Yes, file permissions can be an issue if web server can't access the uploaded file. It is better to avoid cPanel file manager, unless FTP doesn't work for some reason.
Title: Re: TuneIn API Integration
Post by: joshuatree44 on March 30, 2015, 04:40:30 AM
Exactly what I have found over time. It just sucks that things are not happy with things.
Title: Re: TuneIn API Integration
Post by: matti on May 18, 2015, 08:06:16 AM
good call on this feature request, for TuneIn/Twitter/Facebook autoposting!
Title: Re: TuneIn API Integration
Post by: country101 on May 19, 2015, 03:13:59 AM
Code: [Select]
[19-May-2015 01:03:12 UTC] PHP Notice:  Undefined variable: Of in /home/country101/public_html/radiodj/web-export.php on line 4

I am getting this error when I try to use the scripts. Am I doing something wrong? I took out some of the edits so it should say line 11.
Title: Re: TuneIn API Integration
Post by: AndyDeGroo on May 19, 2015, 03:25:33 AM
Code: [Select]
[19-May-2015 01:03:12 UTC] PHP Notice:  Undefined variable: Of in /home/country101/public_html/radiodj/web-export.php on line 4

I am getting this error when I try to use the scripts. Am I doing something wrong? I took out some of the edits so it should say line 11.

PHP interprets variables in strings enclosed in double quotes. Use single quotes instead to wrap the partner ID string. e.g:
Code: [Select]
<?php
$partnerId 
'I0p$Of*y'// TuneIn API partner ID
?>

Title: Re: TuneIn API Integration
Post by: country101 on May 19, 2015, 03:31:23 AM
OK I have made the change. Should I or do I need to change the others? It does not seem to be working at this moment.
http://tunein.com/radio/Country-101-s246803/ (http://tunein.com/radio/Country-101-s246803/)
Title: Re: TuneIn API Integration
Post by: PrairieGhost on June 25, 2015, 02:04:17 AM
I've read through this thread and I'm probably more confused than when I started. I realize I have to email Tunein to get the keys. Do I have to wait for them to populate my station on their site first before I email them? Also the API integration has me completely confused. I know nothing about coding. I'm using a wordpress site and lost. Is there a service that would do this for me if I paid them or am I making this harder in my head than it is?
Title: Re: Plugin or Feature for 'TuneIn API Integration
Post by: makmb on July 03, 2015, 10:18:39 AM
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.


Can not manage to send data to tune in

Url is the following :http://air.radiotime.com/Playing.ashx?partnerId=IU*kuUbu&partnerKey=******=s202294&title=$title$&artist=$artist$

(Removed partner Key) Please don't post keys on here.

[attachment deleted by admin]
Title: Re: TuneIn API Integration
Post by: jbrooks on September 16, 2015, 12:45:01 AM
Try moving the question mark down to the second slot. Not sure if that will help, as I am having the same issue. Also note that Tunein is moving to a Freemium service. Not sure what changes that will mean for content providers. I haven't changed my settings and my metadata has stopped pushing to Tune in... for at least the passed few months.
Title: Re: TuneIn API Integration
Post by: Marius on September 16, 2015, 08:27:44 AM
Sorry, somehow i missed @makmb's post.

In the url you don't have to add the "?" character.
The url is:
Code: [Select]
http://air.radiotime.com/Playing.ashxand the argument (custom data in which you have to replace the data with the rdj variables) is the rest:
Code: [Select]
partnerId=<id>&partnerKey=<key>&id=<stationid>&title=Bad+Romance&artist=Lady+Gaga
Title: Re: TuneIn API Integration
Post by: makmb on September 18, 2015, 09:46:40 AM
Sorry, somehow i missed @makmb's post.

In the url you don't have to add the "?" character.
The url is:
Code: [Select]
http://air.radiotime.com/Playing.ashxand the argument (custom data in which you have to replace the data with the rdj variables) is the rest:
Code: [Select]
partnerId=<id>&partnerKey=<key>&id=<stationid>&title=Bad+Romance&artist=Lady+Gaga

Thanks for the tip. It worked that way. It just needs to leave in custom data, title and artist as it is:
partnerId=<id>&partnerKey=<key>&id=<stationid>&title=$title$&artist=$artist$
!!! Only change red data!!!

Title: Re: TuneIn API Integration
Post by: 70vibe-FM on October 07, 2015, 02:38:46 PM
No, I didn't mean that your keys were wrong. It wasn't working because you had left "<" and ">" in the url.

To put it bluntly;
This was wrong:
Code: [Select]
http://air.radiotime.com/Playing.ashx?partnerId=<CXXXXXYi>&partnerKey=<_aXXXXhKNopL>&id=<s209409>

This is correct:
Code: [Select]
http://air.radiotime.com/Playing.ashx?partnerId=CXXXXXYi&partnerKey=_aXXXXhKNopL&id=s209409

Please pay more attention to instructions and try to understand what you are doing. I've learned many things by trial and error and you should too.
Title: Re: TuneIn API Integration
Post by: rudyz on October 11, 2015, 07:24:11 PM
Please forgive me if I am hijacking this thread, but I thought this the best place to ask the question.

How do I avoid sending artist and title info to TuneIn for commercials and other non music tracks?

The problem is that when using the API, TuneIn attempts to load album art based on the title and artist listed with the commercial file in RDJ. This is despite the fact that in Options/Stream Titles, I have specified $station_name$ - $station_slogan$, or nothing at all for commericals, and other non music files like news and sweepers, etc.

TuneIn API accepts a string such as commercial=true, for which it ignores the artist and title and instead displays the station summary and logo in the TuneIn database.

So my workaround is to make all album info for commercials be "true" in RDJ and in my Web Export URL sent to the API I use commercial=$album", which TuneIn then receives as commercial=true.

This works as a work around but surely I am doing something wrong or there is a better way to do this, as I foresee problems in the future when I need to use the correct album info for these files instead of using "true" in order to get TuneIn to ignore the artist and title info with commercials, news, sweepers, etc.

Title: Re: TuneIn API Integration
Post by: Valdis on October 26, 2015, 01:08:00 AM
Please forgive me if I am hijacking this thread, but I thought this the best place to ask the question.

How do I avoid sending artist and title info to TuneIn for commercials and other non music tracks?

The problem is that when using the API, TuneIn attempts to load album art based on the title and artist listed with the commercial file in RDJ. This is despite the fact that in Options/Stream Titles, I have specified $station_name$ - $station_slogan$, or nothing at all for commericals, and other non music files like news and sweepers, etc.

TuneIn API accepts a string such as commercial=true, for which it ignores the artist and title and instead displays the station summary and logo in the TuneIn database.

So my workaround is to make all album info for commercials be "true" in RDJ and in my Web Export URL sent to the API I use commercial=$album", which TuneIn then receives as commercial=true.

This works as a work around but surely I am doing something wrong or there is a better way to do this, as I foresee problems in the future when I need to use the correct album info for these files instead of using "true" in order to get TuneIn to ignore the artist and title info with commercials, news, sweepers, etc.

Have you tried using "commercial=true" instead of "commercial=$album$" in titles configuration? That should work and you would not have to set album titles to "true".
Title: Re: TuneIn API Integration
Post by: PrairieGhost on December 09, 2015, 02:42:20 AM
I have the AIR API working but after the show is on for a while it defaults back to my station name only without the show info. Anyone know what might be causing this?

Never mind I guess this is a normal thing with tunein.
Title: Re: TuneIn API Integration
Post by: xtrabeat on May 09, 2016, 06:13:34 PM
Hello everyone, I have some doubts ... To TuneIn present our songs, just fill the webexport? is instantaneous updating?
Title: Re: TuneIn API Integration
Post by: xtrabeat on May 17, 2016, 05:04:07 PM
Good afternoon someone to help me with the air TuneIn api?
The setting can be made only by radiodj?
Title: Re: TuneIn API Integration
Post by: Valdis on July 22, 2016, 07:17:30 AM
If anyone who is following this thread wants a better web export plugin which supports track type filtering for posting to TuneIn, there is one now. Take a look at Web Export NG plugin - Advanced web export (http://www.radiodj.ro/community/index.php?topic=8867.0).
Title: Re: TuneIn API Integration
Post by: kegham on October 04, 2016, 05:40:07 PM
<?php

// TuneIn Air API PHP Script for IceCast - AutoDJ support
// CODE HAS BEEN WRITTEN BY KEGHAM DEPOYAN
// http://www.radioarev.com | info@radioarev.com
// Add this script to cron job run every ( Min 15 seconds - Max 1 Min )
// Make sure HTTP WRAPPER must be enabled on your server PHP.ini. ni order to use ( file_get_contents ) function.
// https://cron-job.org \\
//  :) Hope this will help someone who need :)

// -------------------------------------------------------------------------------------\\

// TuneIn API settings
$PartnerID  = 'xxxxxxxx'; // TuneIn partner ID
$PartnerKey = 'xxxxxxxxxxxx'; // TuneIn partner key
$StationID  = 'sxxxxxx'; // TuneIn station ID

// Get file content from streaming server and decode output
$url = 'http://yourstreamingserver.com/rpc/username/streaminfo.get';
$filestring = file_get_contents($url);
$decode = json_decode($filestring, True);

// Read output arrays and seperate them by Artist & Title
$read_artist = $decode['data']['0']['track']['artist'];
$read_title = $decode['data']['0']['track']['title'];

// Urlencode them to send over http://air.radiotime.com ( Tune In )
$artist = urlencode($read_artist);
$title =   urlencode($read_title);

// Finally Send over the required information with all variables
$tunein = "http://air.radiotime.com/Playing.ashx?partnerId={$PartnerID}&partnerKey={$PartnerKey}&id={$StationID}&title={$title}&artist={$artist}";
file_get_contents($tunein);

?>
Title: Re: TuneIn API Integration
Post by: Valdis on October 09, 2016, 12:15:57 PM
Hi Kegham,

You should probably edit your post and remove the BBCode [color] tags from the code sample. Other BBCode code tags are not parsed inside a code tag.
Title: Re: TuneIn API Integration
Post by: DJ Garybaldy on October 09, 2016, 12:29:36 PM
Hi Kegham,

You should probably edit your post and remove the BBCode [color] tags from the code sample. Other BBCode code tags are not parsed inside a code tag.

That maybe my fault it was originally posted without [ code] tags I'll re edit it to remove all the BB code.
Title: Re: TuneIn API Integration
Post by: kegham on October 09, 2016, 06:57:12 PM
Ok sorry for that one yes you were right the color code etc was annoying. I do remove it so its good now and clear   :)
Title: Re: TuneIn API Integration
Post by: bnickles1961 on November 02, 2016, 02:42:07 PM
Just a quick question, when you enter all your info in radiodj, does the changes (displaying) artist and song info take effect right away on tunein or does it take a bit for the info to appear?
Title: Re: TuneIn API Integration
Post by: marcbeinder on November 02, 2016, 03:46:17 PM
Once you get your API keys, it could take up to 24 hours I've noticed. One thing that I did wrong is I mixed up the uppercase I's and lowercase L's. They don't. So I'd be sure to make sure you typed them in correctly.
Title: Re: TuneIn API Integration
Post by: bnickles1961 on November 02, 2016, 06:01:43 PM
Ok, was just wondering also, I was using Sam Broadcaster with tunein. Will my api keys I was given when I was running Sam still work, or do I need to get new api information?
Title: Re: TuneIn API Integration
Post by: marcbeinder on November 02, 2016, 06:29:22 PM
Ok, was just wondering also, I was using Sam Broadcaster with tunein. Will my api keys I was given when I was running Sam still work, or do I need to get new api information?

The API keys are tied to your account, not your automation. Just be sure to stop any other automation program from sending to TuneIn
Title: Re: TuneIn API Integration
Post by: bnickles1961 on November 02, 2016, 06:43:14 PM
Sam Has been completely stopped. I am just having problems putting the info into radiodj.

In the now playing info exporter, in the url I have:

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

In the custom data I have:

partnerId=xxxxxpartnerkey=xxxxx&id=xxxx&title=$title$&artist=$artist$ I removed the < > from the code

Method is set at GET and the enable box is checked

but it is not working.
Title: Re: TuneIn API Integration
Post by: marcbeinder on November 02, 2016, 06:46:35 PM
Sam Has been completely stopped. I am just having problems putting the info into radiodj.

In the now playing info exporter, in the url I have:

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

In the custom data I have:

partnerId=xxxxxpartnerkey=xxxxx&id=xxxx&title=$title$&artist=$artist$ I removed the < > from the code

Method is set at GET and the enable box is checked

but it is not working.

You forgot one of the & signs. Here try this.

partnerId=xxxxx&partnerkey=xxxxx&id=xxxx&title=$title$&artist=$artist$
Title: Re: TuneIn API Integration
Post by: bnickles1961 on November 02, 2016, 06:54:17 PM
I added it and still nothing, I'm gonna keep plugging along and hopefully I can figure it out.
Title: Re: TuneIn API Integration
Post by: marcbeinder on November 02, 2016, 08:56:22 PM
I added it and still nothing, I'm gonna keep plugging along and hopefully I can figure it out.
Okay. Also it might be parterKey and not partnerkey. It's very case sensative.
Title: Re: TuneIn API Integration
Post by: bnickles1961 on November 08, 2016, 07:31:39 PM
I got it working, it was a typo lol Thanks for your help
Title: Re: TuneIn API Integration
Post by: marcbeinder on November 08, 2016, 08:00:05 PM
I got it working, it was a typo lol Thanks for your help
No problem!
Title: Re: TuneIn API Integration
Post by: morgancz on November 13, 2016, 12:53:19 PM
Working like a hell for us too. But TuneIN wants to send additional variable, if commercial goes on air (commercial=true). Is there any way, how to send it only when adv goes onair? Thanks.
Title: Re: TuneIn API Integration
Post by: marcbeinder on November 13, 2016, 03:51:44 PM
Working like a hell for us too. But TuneIN wants to send additional variable, if commercial goes on air (commercial=true). Is there any way, how to send it only when adv goes onair? Thanks.

There's a relatively new now playing plugin the I believe Valdis made. You can choose where to send info and for what track type to send it for. I use it and it's amazing!

Here's the link: http://www.radiodj.ro/community/index.php?topic=8867.0
Title: Re: Plugin or Feature for 'TuneIn API Integration
Post by: ibgradiogroup on November 13, 2016, 11:43:03 PM
Set method to GET and check the Enable check-box.

When using GET, it would not send the information to TuneIn. After changing it to POST, my station has always sent the details to TuneIn for everything it has supposed to.

Not sure if they changed something recently, all I know is this is the only way it works for me.
Title: Re: TuneIn API Integration
Post by: djclewes on September 25, 2020, 05:23:22 PM
Sorry, somehow i missed @makmb's post.

In the url you don't have to add the "?" character.
The url is:
Code: [Select]
http://air.radiotime.com/Playing.ashxand the argument (custom data in which you have to replace the data with the rdj variables) is the rest:
Code: [Select]
partnerId=<id>&partnerKey=<key>&id=<stationid>&title=Bad+Romance&artist=Lady+Gaga



in RadioDJ Web Export it has three boxes

URL

PASSWORD

CUSTOM DATA.


What goes in password ? is that the password i got from tunein or do i leave it blank.

thank you.