Skip to content

Instantly share code, notes, and snippets.


breyten/radioboxify.php Secret

Created Jun 28, 2013
What would you like to do?
Get songs from Radiobox2 and add links to Spoptify
<input type="text" name="q" value="<?php echo $_GET['q']; ?>" />
<input type="submit" value="Verstuur" />
if (trim($_GET['q']) != '') {
$q = $_GET['q'];
$results = json_decode(file_get_contents("'%$q%'"));
} else {
$results = new stdClass();
$results->results = array();
foreach($results->results as $result) {
$artist = $result->songversion[0]->presentable_name;
$title = $result->songversion[0]->title;
$spotify_query = urlencode("$artist $title");
$spotify_info = json_decode(file_get_contents("$spotify_query"));
print "<div class=\"result\">";
print "<h3>$artist - $title</h3>";
print $result->songversion[0]->description;
if ($spotify_info->info->num_results > 0) {
print "<ul>";
foreach ($spotify_info->tracks as $track) {
$track_info = split(':', $track->href);
$track_id = $track_info[2];;
$play_url = "$track_id";
print "<li><a href=\"$play_url\">Speel dit nummer op spotify</a></li>";
print "</ul>";
print "</div>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment