[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
This commit is contained in:
sarnd 2020-07-24 09:52:27 +02:00 committed by GitHub
parent 976445b490
commit 78298385d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -377,7 +377,7 @@ EOD;
if($data === null || !is_array($data) || count($data) != 1) { if($data === null || !is_array($data) || count($data) != 1) {
$twitterPage = getContents('https://twitter.com'); $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); preg_match_all($jsMainRegex, $twitterPage, $jsMainMatches, PREG_SET_ORDER, 0);
$jsLink = $jsMainMatches[0][0]; $jsLink = $jsMainMatches[0][0];
@ -420,6 +420,8 @@ EOD;
$guestTokenRegex = '/gt=([0-9]*)/m'; $guestTokenRegex = '/gt=([0-9]*)/m';
preg_match_all($guestTokenRegex, $pageContent['header'], $guestTokenMatches, PREG_SET_ORDER, 0); 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'); if (!$guestTokenMatches) returnServerError('Could not parse guest token');
$guestToken = $guestTokenMatches[0][1]; $guestToken = $guestTokenMatches[0][1];
return $guestToken; return $guestToken;