Skip to content

Commit 179415b

Browse files
committed
Fix Instagram/Facebook oEmbed calls
1 parent f19655f commit 179415b

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

src/Providers/OEmbed/Facebook.php

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,51 @@
22

33
namespace Embed\Providers\OEmbed;
44

5+
use Embed\Adapters\Adapter;
6+
use Embed\Http\Response;
57
use Embed\Http\Url;
68

79
class Facebook extends EndPoint implements EndPointInterface
810
{
911
protected static $pattern = 'www.facebook.com/*';
12+
protected $key;
13+
14+
/**
15+
* {@inheritdoc}
16+
*/
17+
public static function create(Adapter $adapter)
18+
{
19+
$key = $adapter->getConfig('facebook[key]');
20+
21+
if (!empty($key)) {
22+
return new static($adapter->getResponse(), $key);
23+
}
24+
}
25+
26+
/**
27+
* {@inheritdoc}
28+
*/
29+
protected function __construct(Response $response, $key = null)
30+
{
31+
$this->response = $response;
32+
$this->key = $key;
33+
}
1034

1135
/**
1236
* {@inheritdoc}
1337
*/
1438
public function getEndPoint()
1539
{
1640
if ($this->getUrl()->match(['*/videos/*', '/video.php'])) {
17-
$endPoint = Url::create('https://www.facebook.com/plugins/video/oembed.json');
41+
$endPoint = Url::create('https://graph.facebook.com/v8.0/oembed_video');
1842
} else {
19-
$endPoint = Url::create('https://www.facebook.com/plugins/post/oembed.json');
43+
$endPoint = Url::create('https://graph.facebook.com/v8.0/oembed_post');
2044
}
2145

2246
return $endPoint->withQueryParameters([
2347
'url' => (string) $this->getUrl(),
2448
'format' => 'json',
49+
'access_token' => $this->key,
2550
]);
2651
}
2752
}

src/Providers/OEmbed/Instagram.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Embed\Providers\OEmbed;
44

5+
use Embed\Adapters\Adapter;
6+
use Embed\Http\Response;
57
use Embed\Http\Url;
68

79
class Instagram extends EndPoint implements EndPointInterface
@@ -11,7 +13,29 @@ class Instagram extends EndPoint implements EndPointInterface
1113
'www.instagram.com/p/*',
1214
'instagr.am/p/*',
1315
];
14-
protected static $endPoint = 'https://api.instagram.com/oembed';
16+
protected static $endPoint = 'https://graph.facebook.com/v8.0/instagram_oembed';
17+
protected $key;
18+
19+
/**
20+
* {@inheritdoc}
21+
*/
22+
public static function create(Adapter $adapter)
23+
{
24+
$key = $adapter->getConfig('facebook[key]');
25+
26+
if (!empty($key)) {
27+
return new static($adapter->getResponse(), $key);
28+
}
29+
}
30+
31+
/**
32+
* {@inheritdoc}
33+
*/
34+
protected function __construct(Response $response, $key = null)
35+
{
36+
$this->response = $response;
37+
$this->key = $key;
38+
}
1539

1640
/**
1741
* {@inheritdoc}
@@ -24,6 +48,7 @@ public function getEndPoint()
2448
->withQueryParameters([
2549
'url' => (string) $url,
2650
'format' => 'json',
51+
'access_token' => $this->key,
2752
]);
2853
}
2954
}

0 commit comments

Comments
 (0)