Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/Adapters/Vimeo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Embed\Adapters;

use Embed\Request;
use Embed\Providers;

/**
* Adapter to provide information from Vimeo.
* Required when Vimeo returns a 403 status code.
*/
class Vimeo extends Webpage implements AdapterInterface
{

/**
* {@inheritdoc}
*/
public static function check(Request $request)
{
return $request->isValid([200, 403]) && $request->match([
'https?://*.vimeo.com*',
'https?://vimeo.com*',
]);
}

/**
* @inheritDoc
*/
protected function run()
{
if ($this->request->getHttpCode() === 403) {
$this->addProvider('oembed', new Providers\OEmbed());

return;
}

parent::run();
}

}
38 changes: 38 additions & 0 deletions src/Providers/OEmbed/Vimeo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Embed\Providers\OEmbed;

use Embed\Url;

class Vimeo extends OEmbedImplementation
{

/**
* @inheritDoc
*/
public static function getEndPoint(Url $url)
{
return 'https://vimeo.com/api/oembed.json';
}

/**
* @inheritDoc
*/
public static function getPatterns()
{
return [
'https?://*.vimeo.com*',
'https?://vimeo.com*',
];
}

/**
* @inheritDoc
*/
public static function getParams(Url $url)
{
return [
'url' => $url->withScheme('http')->getUrl(),
];
}
}