Esempio n. 1
0
     $plist = array();
     foreach (Songs::getPostListByUser($user) as $idx => $post) {
         $plist[] = array('id' => $post['id'], 'title' => $post['title'], 'a_id' => $post['artist_id'], 'artist' => $post['artist'], 'artwork_url' => $post['artwork_url']);
     }
     header('Content-type: application/json');
     print json_encode($plist);
     exit;
 } else {
     if ($resource_type == 'home') {
         header('HTTP/1.1 400 Bad Request');
         print "Too many resources for home";
         exit;
     } else {
         if ($resource_type == 'songinfo') {
             $songid = $resource_components[2];
             $song = Songs::getPostByID($songid);
             $song = $song->getJSON();
             header('Content-type: application/json');
             print $song;
             exit;
         } else {
             if ($resource_type == 'queue') {
                 $user = $resource_components[2];
                 foreach (SongQueue::getUsersQueue($user) as $idx => $song) {
                     $queue[] = array('user' => $song['user'], 'song' => $song['song'], 'title' => $song['title'], 'a_id' => $song['artist_id'], 'artist' => $song['artist'], 'art' => $song['art'], 'position' => $song['position']);
                 }
                 header('Content-type: application/json');
                 print json_encode($queue);
                 exit;
             }
         }