/**
  * Fetches the JSON data from the Oembed URL (cached).
  * Only sets the internal variable.
  */
 protected function loadData()
 {
     //Get the video id
     $videoID = Vidyard::getVidyardCode($this->url);
     if (empty($videoID)) {
         return false;
     }
     $this->videoID = $videoID;
     //Retrieve and Check the api key
     $apiKey = Vidyard::config()->api_key;
     if (empty($apiKey)) {
         return false;
     }
     if ($this->data !== false) {
         return;
     }
     // Fetch from Oembed URL (cache for a week by default)
     $service = new VidyardService($videoID, $apiKey, 60 * 60 * 24 * 7);
     $body = $service->request();
     if (!$body || $body->isError()) {
         $this->data = array();
         return;
     }
     //Get the json response
     $data = $body->json();
     // Convert all keys to lowercase
     $data = array_change_key_case($data, CASE_LOWER);
     $data = array('version' => '1.0', 'thumbnail_url' => 'https://play.vidyard.com/' . rawurlencode($videoID) . '.jpg', 'type' => 'video', 'provider_name' => 'Vidyard', 'provider_url' => 'https://www.vidyard.com/', 'width' => $data['width'], 'height' => $data['height'], 'title' => $data['name'], 'html' => '<script type="text/javascript" id="vidyard_embed_code_' . Convert::raw2att($videoID) . '" src="//play.vidyard.com/' . rawurlencode($videoID) . '.js?v=3.0&type=inline"></script>');
     // Purge everything if the type does not match.
     if ($this->type && $this->type != $data['type']) {
         $data = array();
     }
     $this->data = $data;
 }
 /**
  * Fetches the JSON data from the Oembed URL (cached).
  * Only sets the internal variable.
  */
 protected function loadData()
 {
     //Get the video id
     $videoID = Vidyard::getVidyardCode($this->url);
     if (empty($videoID)) {
         return false;
     }
     $this->videoID = $videoID;
     //Retrieve and Check the api key
     $apiKey = Vidyard::config()->api_key;
     if (empty($apiKey)) {
         return false;
     }
     if ($this->data !== false) {
         return;
     }
     // Fetch from Oembed URL (cache for a week by default)
     $service = new VidyardService($videoID, $apiKey, 60 * 60 * 24 * 7);
     $body = $service->request();
     if (!$body || $body->isError()) {
         $this->data = array();
         return;
     }
     //Get the json response
     $data = $body->json();
     // Convert all keys to lowercase
     $data = array_change_key_case($data, CASE_LOWER);
     $data = array('version' => '1.0', 'thumbnail_url' => 'https://play.vidyard.com/' . rawurlencode($videoID) . '.jpg', 'type' => 'video', 'provider_name' => 'Vidyard', 'provider_url' => 'https://www.vidyard.com/', 'width' => $data['width'], 'height' => $data['height'], 'title' => $data['name']);
     $data['html'] = $this->customise(array('RawVideoData' => new ArrayData($data), 'VideoID' => $videoID, 'FunctionVideoID' => preg_replace('/[^0-9a-zA-Z_$]/', '$', $videoID), 'UseLightbox' => $this->_useLightbox))->renderWith('VidyardVideo_inner');
     // Purge everything if the type does not match.
     if ($this->type && $this->type != $data['type']) {
         $data = array();
     }
     $this->data = $data;
 }