_service = new SoundcloudService(); } /** * Fetch the permalink to a file on SoundCloud and redirect to it. */ public function viewOnSoundCloudAction() { $request = $this->getRequest(); $id = $request->getParam('id'); try { $soundcloudLink = $this->_service->getLinkToFile($id); header('Location: ' . $soundcloudLink); } catch (Soundcloud\Exception\InvalidHttpResponseCodeException $e) { // Redirect to a 404 so the user knows something went wrong header('Location: ' . $this->_baseUrl . 'error/error-404'); } } }