Skip to content

Commit 2cc92c3

Browse files
authored
Follow Facebook login redirect
Facebook redirects to login for all posts, but with a token the OEmbed info is still readable. This change gets the original url from the `next` query parameter of the redirected login and queries the relevant oembed endpoint. Fixes #450
1 parent 68fe4ba commit 2cc92c3

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/Adapters/Facebook/OEmbed.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
class OEmbed extends Base
1010
{
11-
const ENDPOINT_PAGE = 'https://graph.facebook.com/v8.0/oembed_page';
12-
const ENDPOINT_POST = 'https://graph.facebook.com/v8.0/oembed_post';
13-
const ENDPOINT_VIDEO = 'https://graph.facebook.com/v8.0/oembed_video';
11+
const ENDPOINT_PAGE = 'https://graph.facebook.com/v11.0/oembed_page';
12+
const ENDPOINT_POST = 'https://graph.facebook.com/v11.0/oembed_post';
13+
const ENDPOINT_VIDEO = 'https://graph.facebook.com/v11.0/oembed_video';
1414

1515
protected function detectEndpoint(): ?UriInterface
1616
{
@@ -21,6 +21,16 @@ protected function detectEndpoint(): ?UriInterface
2121
}
2222

2323
$uri = $this->extractor->getUri();
24+
if (strpos($uri->getPath(), 'login') !== false) {
25+
$query = $uri->getQuery();
26+
$params = explode('&', $query);
27+
foreach ($params as $param) {
28+
$keyval = explode('=', $param);
29+
if ($keyval[0] == 'next') {
30+
$uri = $this->extractor->getCrawler()->createUri(rawurldecode($keyval[1]));
31+
}
32+
}
33+
}
2434
$queryParameters = $this->getOembedQueryParameters((string) $uri);
2535
$queryParameters['access_token'] = $token;
2636

0 commit comments

Comments
 (0)