[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:
parent
976445b490
commit
78298385d0
1 changed files with 3 additions and 1 deletions
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue