-2

this ist my JSON File. I'am going to parse the "Titel" and the "Album" in PHP so:

Current Song: Titel (Album)

How can I make this with PHP? Can anybody post me the full PHP File?

Finn
  • 1
  • 1
  • 2

1 Answers1

1

well, this should be rather straightforward:

<?php

function get_content($URL){
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_URL, $URL);
      $data = curl_exec($ch);
      curl_close($ch);
      return $data;
}

//$json = file_get_contents("http://api.laut.fm/station/radiojfm/current_song");

$json = get_content("http://api.laut.fm/station/radiojfm/current_song");
$data = json_decode($json, true);

echo $data["title"]." ".$data["album"];

?>
ewcz
  • 12,064
  • 1
  • 21
  • 44