[TwitterBridge] URL to js file with apikey changed. (#1686)

Twitter has changed URL scheme back again (see PR#1647 / commit 78298385d0)

This patch will try both URL schemes now and throw a specific error when neither works
This commit is contained in:
sarnd 2020-08-06 07:22:17 +02:00 committed by GitHub
parent 5be251a66e
commit c71fad4a4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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\/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);