Skip to content
Permalink
Browse files

Add Vimeo as a provider

Add Vimeo as a provider so as to take advantage of the oEmbed endpoint.

Vimeo has started to ban IP blocks from popular providers  (DigitalOcean, Vultr, Google Cloud) due to malicious behaviour from some IPs but subsequently affecting legitimate use cases. The ban results in 403 error codes when attempting to embed URLs using the standard "webpage" adapter, however oEmbed is unaffected.
  • Loading branch information...
bendesilva committed Sep 16, 2019
1 parent 960bbd5 commit 55df81e4fc9a5eafcf5ee0beaf77b6f30c41a138
Showing with 51 additions and 0 deletions.
  1. +22 −0 src/Adapters/Vimeo.php
  2. +9 −0 src/Providers/OEmbed/Vimeo.php
  3. +20 −0 tests/VimeoTest.php
@@ -0,0 +1,22 @@
<?php
namespace Embed\Adapters;
use Embed\Http\Response;
/**
* Adapter to provide information from Vimeo.
* Required when Vimeo returns a 403 status code.
*/
class Vimeo extends Webpage
{
/**
* {@inheritdoc}
*/
public static function check(Response $response)
{
return $response->isValid([200, 403]) && $response->getUrl()->match([
'vimeo.com/*',
]);
}
}
@@ -0,0 +1,9 @@
<?php
namespace Embed\Providers\OEmbed;
class Vimeo extends EndPoint implements EndPointInterface
{
protected static $pattern = ['vimeo.com/*'];
protected static $endPoint = 'https://vimeo.com/api/oembed.json';
}
@@ -0,0 +1,20 @@
<?php
namespace Embed\Tests;
class VimeoTest extends AbstractTestCase
{
public function testOne()
{
$this->assertEmbed(
'https://vimeo.com/235352744',
[
'title' => 'Vimeo Live is here',
'providerName' => 'Vimeo',
'width' => 640,
'height' => 360,
'code' => '<iframe src="https://player.vimeo.com/video/235352744?app_id=122963" width="640" height="360" frameborder="0" allow="autoplay; fullscreen" allowfullscreen title="Vimeo Live is here"></iframe>',
]
);
}
}

0 comments on commit 55df81e

Please sign in to comment.
You can’t perform that action at this time.