コード例 #1
0
ファイル: OEmbedCrawler.php プロジェクト: flamecore/flink
 /**
  * {@inheritdoc}
  */
 public function crawl($url)
 {
     try {
         $http = new HttpClient($this->userAgent);
         $oembed = new OEmbed(null, $http);
         if ($provider = $this->findProvider($url)) {
             $media = $oembed->fetch($url, $provider);
         } else {
             $media = $oembed->discover($url);
         }
         if (!$media) {
             return false;
         }
         return array('title' => $media->title, 'description' => null, 'type' => $this->determineMediaType($media->type), 'images' => $this->createImagesList($media));
     } catch (\Exception $e) {
         return false;
     }
 }
コード例 #2
0
 /**
  * Replaces the given URL with its HTML representation.
  *
  * @param string $url The media URL
  * @param array $args An array of arguments
  * @return false|string
  */
 protected function replace($url, array $args)
 {
     if ($provider = $this->providers->findProvider($url)) {
         return $this->oembed->getHTML($url, $provider, $args);
     } elseif ($this->isDiscoveryEnabled()) {
         return $this->oembed->getHTML($url, null, $args);
     }
     return false;
 }