• 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

AndyDeGroo

Did you paste your credentials at the beginning of file? For example:

<?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.

Chrispy

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.

$partnerId = 'z9bVxxxx'; // TuneIn API partner ID
$partnerKey = 'xxxxxxs8j$qe'; // TuneIn API partner key
$stationId = 's195xxx'; // TuneIn API station ID

rogiermaas

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
DJ Garybaldy is RIGHT! RadioDJ WILL defeat the Evil SAM!
Musicbox Live! - musicboxlive.nl

AndyDeGroo

Quote from: 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.

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:

<?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:

<?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>"
?>





elsilva0

Wut does this implement or tunein agreement do?

AndyDeGroo

Quote from: elsilva0 on October 11, 2014, 02:35:18 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? 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.

elsilva0

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:

AndyDeGroo

Compare your TuneIn page with this one. You may see that there is a list of played songs and when you click "expand", there is description and images of an artist.

HMC

Quote from: 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:
Quote from: AndyDeGroo on October 11, 2014, 06:52:47 AM
Compare your TuneIn page with this one. 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/

Radio DJ 1.7.5 Update with MariaDB 10

AndyDeGroo

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.

HMC

Quote from: 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.

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.
Radio DJ 1.7.5 Update with MariaDB 10

Chrispy

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.

elsilva0

Where is the link to get the Tune in API?

AndyDeGroo

Quote from: elsilva0 on November 10, 2014, 11:39:07 PM
Where is the link to get the Tune in API?
Did you read the TuneIn API documentation? You have to request API keys by sending an email.

elsilva0

Quote from: AndyDeGroo on November 10, 2014, 11:54:58 PM
Did you read the TuneIn API documentation? 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