Skip to content

Commit 5a17bdf

Browse files
committed
added support for iframe.ly as fallback oembed provider
1 parent 333fdfd commit 5a17bdf

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ The providers get the data from different sources. Each source has it's own prov
102102
Used to get data from oembed api if it's available. It accepts two options:
103103

104104
* parameters (array): Extra query parameters to send with the oembed request
105-
* embedlyKey (string): If it's defined and the page has not its own oembed service, use the embedly api.
105+
* embedlyKey (string): If it's defined, use embed.ly api as fallback oembed provider.
106+
* iframelyKey (string): If it's defined, use iframe.ly api as fallback oembed provider.
106107

107108
#### html
108109

src/Providers/OEmbed.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class OEmbed extends Provider implements ProviderInterface
1515
protected $config = [
1616
'parameters' => [],
1717
'embedlyKey' => null,
18+
'iframelyKey' => null,
1819
];
1920

2021
/**
@@ -252,6 +253,14 @@ protected static function getEndPointFromRequest(Request $request, array $config
252253
'params' => OEmbed\Embedly::getParams($request) + ['key' => $config['embedlyKey']],
253254
];
254255
}
256+
257+
//Search using iframely
258+
if (!empty($config['iframelyKey']) && $request->match(OEmbed\Iframely::getPatterns())) {
259+
return [
260+
'endPoint' => OEmbed\Iframely::getEndpoint($request),
261+
'params' => OEmbed\Iframely::getParams($request) + ['api_key' => $config['iframelyKey']],
262+
];
263+
}
255264
}
256265

257266
/**

src/Providers/OEmbed/Iframely.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Embed\Providers\OEmbed;
4+
5+
use Embed\Url;
6+
7+
class Iframely extends OEmbedImplementation
8+
{
9+
/**
10+
* {@inheritdoc}
11+
*/
12+
public static function getEndPoint(Url $url)
13+
{
14+
return 'http://open.iframe.ly/api/oembed';
15+
}
16+
17+
/**
18+
* {@inheritdoc}
19+
*/
20+
public static function getPatterns()
21+
{
22+
return '*';
23+
}
24+
}

0 commit comments

Comments
 (0)