/** * @param $album_id spotify uri */ function getAlbumDetails($album_id) { if (!is_spotify_uri($album_id)) { return false; } $url = 'http://ws.spotify.com/lookup/1/?uri=' . $album_id . '&extras=trackdetail'; $http = new HttpClient($url); // $http->setCacheTime(60*60*24); //24 hours $data = $http->getBody(); if ($http->getStatus() != 200) { d('SpotifyMetadata->getAlbumDetails server error: ' . $http->getStatus()); d($http->getResponseHeaders()); return false; } return $this->parseAlbumDetails($data); }
/** * Returns details on a movie * * @param $movie_id TMDB id */ public function getInfo($movie_id) { if (!self::probeId($movie_id)) { throw new \Exception('not a tmdb id'); } if ($this->cache_results) { $temp = TempStore::getInstance(); $key = 'TheMovieDbClient/info//' . $movie_id; $data = $temp->get($key); if ($data) { return unserialize($data); } } $url = 'http://api.themoviedb.org/3/movie/' . $movie_id . '?language=' . $this->language . '&api_key=' . $this->api_key; $http = new HttpClient($url); $data = $http->getBody(); if ($http->getStatus() != 200) { d('TheMovieDbClient getInfo server error: ' . $http->getStatus()); d($http->getResponseHeaders()); return false; } $res = Json::decode($data); if ($this->cache_results) { $temp->set($key, serialize($res), '24h'); } return $res; }