From 78298385d0016a7db8ed00894d9004429d24e77d Mon Sep 17 00:00:00 2001 From: sarnd <34441397+sarnd@users.noreply.github.com> Date: Fri, 24 Jul 2020 09:52:27 +0200 Subject: [PATCH] [TwitterBridge] guest token is returned via body again. (#1647) * [TwitterBridge] guest token is returned via body again. This change will try to search fot token inside header and fallback to body * Twitter changed the URL scheme for the API --- bridges/TwitterBridge.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bridges/TwitterBridge.php b/bridges/TwitterBridge.php index e9728f96..daf52fb2 100644 --- a/bridges/TwitterBridge.php +++ b/bridges/TwitterBridge.php @@ -377,7 +377,7 @@ EOD; if($data === null || !is_array($data) || count($data) != 1) { $twitterPage = getContents('https://twitter.com'); - $jsMainRegex = '/(https:\/\/abs\.twimg\.com\/responsive-web\/web\/main\.[^\.]+\.js)/m'; + $jsMainRegex = '/(https:\/\/abs\.twimg\.com\/responsive-web\/web_legacy\/main\.[^\.]+\.js)/m'; preg_match_all($jsMainRegex, $twitterPage, $jsMainMatches, PREG_SET_ORDER, 0); $jsLink = $jsMainMatches[0][0]; @@ -420,6 +420,8 @@ EOD; $guestTokenRegex = '/gt=([0-9]*)/m'; preg_match_all($guestTokenRegex, $pageContent['header'], $guestTokenMatches, PREG_SET_ORDER, 0); + if (!$guestTokenMatches) + preg_match_all($guestTokenRegex, $pageContent['content'], $guestTokenMatches, PREG_SET_ORDER, 0); if (!$guestTokenMatches) returnServerError('Could not parse guest token'); $guestToken = $guestTokenMatches[0][1]; return $guestToken;