Esempio n. 1
0
<?php

require_once "../vendor/autoload.php";
if (empty($_GET['url'])) {
    die('Provide a valid url as a query parameter (e.g. ?url=example.org)');
}
$extract = new \pmill\Extract\Extract();
$result = $extract->extract($_GET['url']);
print_r($result);
echo "<BR><BR>";
if ($result instanceof \pmill\Extract\ExtractedVideo) {
    echo '<iframe src="' . $result->getEmbedUrl() . '" frameborder="0"></iframe>';
}
if ($result instanceof \pmill\Extract\ExtractedImage) {
    echo '<img src="' . $result->getSource() . '" />';
}
if ($result instanceof \pmill\Extract\ExtractedAlbum) {
    foreach ($result->getImages() as $image) {
        echo '<img src="' . $image->getSource() . '" /><br><br>';
    }
    foreach ($result->getVideos() as $video) {
        echo '<iframe src="' . $video->getEmbedUrl() . '" frameborder="0"></iframe>';
        if ($video->getThumbnail()) {
            echo '<img src="' . $video->getThumbnail()->getSource() . '" />';
        }
        echo '<br><br>';
    }
}
Esempio n. 2
0
 /**
  * @dataProvider dataFindProvider
  */
 public function testFindProvider($url, $className)
 {
     $extract = new \pmill\Extract\Extract();
     $providerClassName = $extract->findProvider($url);
     $this->assertEquals($className, $providerClassName);
 }