/**
  * Gets the video by it's url
  * @param {string} $url Vidyard Video URL to lookup
  * @return {array} Array in which the first key is a file instance and the second key is the url
  */
 protected function getVideoByURL($url)
 {
     //Get the video id
     $videoID = Vidyard::getVidyardCode($url);
     if (empty($videoID)) {
         $exception = new SS_HTTPResponse_Exception('Could not get the Video ID from the URL', 400);
         $exception->getResponse()->addHeader('X-Status', $exception->getMessage());
         throw $exception;
     }
     //Retrieve and Check the api key
     $apiKey = Vidyard::config()->api_key;
     if (empty($apiKey)) {
         $exception = new SS_HTTPResponse_Exception('Vidyard.api_key is not set, please configure your api key see http://support.vidyard.com/articles/Public_Support/Using-the-Vidyard-dashboard-API/ for how to get your API key.', 401);
         $exception->getResponse()->addHeader('X-Status', $exception->getMessage());
         throw $exception;
     }
     return array(new File(array('Title' => $videoID, 'Filename' => trim($url))), trim($url));
 }
Ejemplo n.º 2
0
 protected function viewfile_getRemoteFileByURL($fileUrl)
 {
     $scheme = strtolower(parse_url($fileUrl, PHP_URL_SCHEME));
     $allowed_schemes = self::config()->fileurl_scheme_whitelist;
     if (!$scheme || $allowed_schemes && !in_array($scheme, $allowed_schemes)) {
         $exception = new SS_HTTPResponse_Exception("This file scheme is not included in the whitelist", 400);
         $exception->getResponse()->addHeader('X-Status', $exception->getMessage());
         throw $exception;
     }
     $domain = strtolower(parse_url($fileUrl, PHP_URL_HOST));
     $allowed_domains = self::config()->fileurl_domain_whitelist;
     if (!$domain || $allowed_domains && !in_array($domain, $allowed_domains)) {
         $exception = new SS_HTTPResponse_Exception("This file hostname is not included in the whitelist", 400);
         $exception->getResponse()->addHeader('X-Status', $exception->getMessage());
         throw $exception;
     }
     return array(new File(array('Title' => basename($fileUrl), 'Filename' => $fileUrl)), $fileUrl);
 }