File tree Expand file tree Collapse file tree 2 files changed +78
-0
lines changed Expand file tree Collapse file tree 2 files changed +78
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Embed \Adapters ;
4+
5+ use Embed \Request ;
6+ use Embed \Providers ;
7+
8+ /**
9+ * Adapter to provide information from Vimeo.
10+ * Required when Vimeo returns a 403 status code.
11+ */
12+ class Vimeo extends Webpage implements AdapterInterface
13+ {
14+
15+ /**
16+ * {@inheritdoc}
17+ */
18+ public static function check (Request $ request )
19+ {
20+ return $ request ->isValid ([200 , 403 ]) && $ request ->match ([
21+ 'https?://*.vimeo.com* ' ,
22+ 'https?://vimeo.com* ' ,
23+ ]);
24+ }
25+
26+ /**
27+ * @inheritDoc
28+ */
29+ protected function run ()
30+ {
31+ if ($ this ->request ->getHttpCode () === 403 ) {
32+ $ this ->addProvider ('oembed ' , new Providers \OEmbed ());
33+
34+ return ;
35+ }
36+
37+ parent ::run ();
38+ }
39+
40+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Embed \Providers \OEmbed ;
4+
5+ use Embed \Url ;
6+
7+ class Vimeo extends OEmbedImplementation
8+ {
9+
10+ /**
11+ * @inheritDoc
12+ */
13+ public static function getEndPoint (Url $ url )
14+ {
15+ return 'https://vimeo.com/api/oembed.json ' ;
16+ }
17+
18+ /**
19+ * @inheritDoc
20+ */
21+ public static function getPatterns ()
22+ {
23+ return [
24+ 'https?://*.vimeo.com* ' ,
25+ 'https?://vimeo.com* ' ,
26+ ];
27+ }
28+
29+ /**
30+ * @inheritDoc
31+ */
32+ public static function getParams (Url $ url )
33+ {
34+ return [
35+ 'url ' => $ url ->withScheme ('http ' )->getUrl (),
36+ ];
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments