From c71fad4a4a9070f4aed6619abc45886ea691aa9e Mon Sep 17 00:00:00 2001 From: sarnd <34441397+sarnd@users.noreply.github.com> Date: Thu, 6 Aug 2020 07:22:17 +0200 Subject: [PATCH] [TwitterBridge] URL to js file with apikey changed. (#1686) Twitter has changed URL scheme back again (see PR#1647 / commit 78298385d0016a7db8ed00894d9004429d24e77d) This patch will try both URL schemes now and throw a specific error when neither works --- bridges/TwitterBridge.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bridges/TwitterBridge.php b/bridges/TwitterBridge.php index 55aed722..6d4898c8 100644 --- a/bridges/TwitterBridge.php +++ b/bridges/TwitterBridge.php @@ -377,8 +377,15 @@ EOD; if($data === null || (time() - $refresh) > self::GUEST_TOKEN_EXPIRY) { $twitterPage = getContents('https://twitter.com'); - $jsMainRegex = '/(https:\/\/abs\.twimg\.com\/responsive-web\/web_legacy\/main\.[^\.]+\.js)/m'; + $jsMainRegex = '/(https:\/\/abs\.twimg\.com\/responsive-web\/web\/main\.[^\.]+\.js)/m'; preg_match_all($jsMainRegex, $twitterPage, $jsMainMatches, PREG_SET_ORDER, 0); + if (!$jsMainMatches) { + $jsMainRegex = '/(https:\/\/abs\.twimg\.com\/responsive-web\/web_legacy\/main\.[^\.]+\.js)/m'; + preg_match_all($jsMainRegex, $twitterPage, $jsMainMatches, PREG_SET_ORDER, 0); + } + if (!$jsMainMatches) { + returnServerError('Could not locate main.js link'); + } $jsLink = $jsMainMatches[0][0]; $jsContent = getContents($jsLink);