Esempio n. 1
0
         header('Content-type: application/json');
         print json_encode($plist);
         exit;
     } else {
         if ($resource_type == 'home') {
             header('HTTP/1.1 200 Success');
             print "Success";
             exit;
         }
     }
 }
 if (count($resource_components) == 3) {
     if ($resource_type == 'posts') {
         $user = $resource_components[2];
         $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();