예제 #1
0
 static function load($url, $result)
 {
     $response = parent::readUrl('https://www.facebook.com/plugins/video/oembed.json/?url=' . urlencode($url));
     $result->rawResponse = $response;
     $data = json_decode($response, true);
     if (is_array($data)) {
         $urlParts = explode('/', trim($url, '/'));
         $videoID = $urlParts[sizeof($urlParts) - 1];
         if (is_numeric($videoID)) {
             $result->width = parent::getIntValueOrNull($data, 'width');
             $result->height = parent::getIntValueOrNull($data, 'height');
             $result->html = '<iframe src="https://www.facebook.com/video/embed?video_id=' . $videoID . '" width="' . $result->width . '" height="' . $result->height . '" frameborder="0"></iframe>';
             $result->duration = parent::getIntValueOrNull($data, 'duration');
             $result->title = parent::getStringValueOrNull($data, 'title');
             $result->description = parent::getStringValueOrNull($data, 'description');
             $result->thumbnail['url'] = parent::getStringValueOrNull($data, 'thumbnail_url');
             $result->thumbnail['width'] = parent::getIntValueOrNull($data, 'thumbnail_width');
             $result->thumbnail['height'] = parent::getIntValueOrNull($data, 'thumbnail_height');
             $result->author['name'] = parent::getStringValueOrNull($data, 'author_name');
             $result->author['url'] = parent::getStringValueOrNull($data, 'author_url');
             $result->provider['name'] = parent::getStringValueOrNull($data, 'provider_name');
             $result->provider['url'] = parent::getStringValueOrNull($data, 'provider_url');
         }
     }
 }
예제 #2
0
 static function load($url, $result)
 {
     $response = parent::readUrl('https://www.youtube.com/oembed?url=' . urlencode($url) . '&format=json');
     $result->rawResponse = $response;
     $data = json_decode($response, true);
     if (is_array($data)) {
         $result->html = parent::getStringValueOrNull($data, 'html');
         $result->width = parent::getIntValueOrNull($data, 'width');
         $result->height = parent::getIntValueOrNull($data, 'height');
         $result->title = parent::getStringValueOrNull($data, 'title');
         $result->thumbnail['url'] = parent::getStringValueOrNull($data, 'thumbnail_url');
         $result->thumbnail['width'] = parent::getIntValueOrNull($data, 'thumbnail_width');
         $result->thumbnail['height'] = parent::getIntValueOrNull($data, 'thumbnail_height');
         $result->author['name'] = parent::getStringValueOrNull($data, 'author_name');
         $result->author['url'] = parent::getStringValueOrNull($data, 'author_url');
         $result->provider['name'] = parent::getStringValueOrNull($data, 'provider_name');
         $result->provider['url'] = parent::getStringValueOrNull($data, 'provider_url');
     }
 }
예제 #3
0
 static function load($url, $result)
 {
     $response = parent::readUrl('http://hulu.com/api/oembed.json?url=' . urlencode($url));
     $result->rawResponse = $response;
     $data = json_decode($response, true);
     if (is_array($data)) {
         $result->html = parent::getStringValueOrNull($data, 'html');
         $result->width = parent::getIntValueOrNull($data, 'width');
         $result->height = parent::getIntValueOrNull($data, 'height');
         $result->duration = parent::getIntValueOrNull($data, 'duration');
         $result->title = parent::getStringValueOrNull($data, 'title');
         $result->description = parent::getStringValueOrNull($data, 'description');
         $result->thumbnail['url'] = parent::getStringValueOrNull($data, 'large_thumbnail_url');
         $result->thumbnail['width'] = parent::getIntValueOrNull($data, 'large_thumbnail_width');
         $result->thumbnail['height'] = parent::getIntValueOrNull($data, 'large_thumbnail_height');
         $result->author['name'] = parent::getStringValueOrNull($data, 'author_name');
         $result->author['url'] = parent::getStringValueOrNull($data, 'author_url');
         $result->provider['name'] = parent::getStringValueOrNull($data, 'provider_name');
         $result->provider['url'] = parent::getStringValueOrNull($data, 'provider_url');
     }
 }
예제 #4
0
 static function load($url, $result)
 {
     $response = parent::readUrl('http://www.vbox7.com/etc/oembed/?url=' . urlencode($url));
     $result->rawResponse = $response;
     $domDocument = new \DOMDocument();
     $domDocument->loadXML($response);
     if ($domDocument->childNodes->item(0)->nodeName === 'oembed') {
         $properties = [];
         $findProperty = function ($name) use($domDocument, &$properties) {
             $elements = $domDocument->getElementsByTagName($name);
             if ($elements->length === 1) {
                 $properties[$name] = trim((string) $elements->item(0)->textContent);
             }
         };
         $findProperty('title');
         $findProperty('author_name');
         $findProperty('author_url');
         $findProperty('provider_name');
         $findProperty('provider_url');
         $findProperty('width');
         $findProperty('height');
         $findProperty('url');
         $urlParts = explode('play:', $properties['url']);
         if (isset($urlParts[1])) {
             $result->width = parent::getIntValueOrNull($properties, 'width');
             $result->height = parent::getIntValueOrNull($properties, 'height');
             $result->html = '<iframe src="https://www.vbox7.com/emb/external.php?vid=' . $urlParts[1] . '" frameborder="0" allowfullscreen style="width:' . $result->width . 'px;height:' . $result->height . 'px;"></iframe>';
             $result->title = parent::getStringValueOrNull($properties, 'title');
             $result->thumbnail['url'] = parent::getStringValueOrNull($properties, 'thumbnail_url');
             $result->thumbnail['width'] = parent::getIntValueOrNull($properties, 'thumbnail_width');
             $result->thumbnail['height'] = parent::getIntValueOrNull($properties, 'thumbnail_height');
             $result->author['name'] = parent::getStringValueOrNull($properties, 'author_name');
             $result->author['url'] = parent::getStringValueOrNull($properties, 'author_url');
             $result->provider['name'] = parent::getStringValueOrNull($properties, 'provider_name');
             $result->provider['url'] = parent::getStringValueOrNull($properties, 'provider_url');
         }
     }
 }