Esempio n. 1
0
 /**
  * Gets details from the referenced artist
  *
  * @param String[Required] $id
  * @return String
  */
 public function getDetails($id)
 {
     // If it's an ajax search
     $json_content = file_get_contents('php://input');
     if ($json_content) {
         // Gets JSON request to read country name typed
         $data = json_decode($json_content);
         $id = $data->id;
         $response = array();
         // Gets details from artist
         $artist = new Artist();
         $artist_info = $artist->getById($id);
         $response['name'] = $artist_info['name'];
         $response['img'] = $artist_info['img'];
         // Gets top tracks
         $response['tracks'] = $artist->getTopTracks($id);
         // Returns JSON for AngularJS
         print json_encode($response);
         exit;
     }
     // If it's a GET request, just displays the HTML
     $template = 'views/artist/details.html';
     $html = file_get_contents($template);
     $html = str_replace('$id', $id, $html);
     print $html;
 }