File tree Expand file tree Collapse file tree 2 files changed +53
-3
lines changed Expand file tree Collapse file tree 2 files changed +53
-3
lines changed Original file line number Diff line number Diff line change 22
33namespace Embed \Providers \OEmbed ;
44
5+ use Embed \Adapters \Adapter ;
6+ use Embed \Http \Response ;
57use Embed \Http \Url ;
68
79class 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}
Original file line number Diff line number Diff line change 22
33namespace Embed \Providers \OEmbed ;
44
5+ use Embed \Adapters \Adapter ;
6+ use Embed \Http \Response ;
57use Embed \Http \Url ;
68
79class 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}
You can’t perform that action at this time.
0 commit comments