From e87b868307761c6241fd12669b8c80b1a0c5408b Mon Sep 17 00:00:00 2001 From: sarnd <34441397+sarnd@users.noreply.github.com> Date: Thu, 25 Jun 2020 12:21:48 +0200 Subject: [PATCH] [TwitterBridge] Fix issue #1621 @ failed with error 429 (#1622) * [TwitterBridge] Fix issue #1621 @ failed with error 429 --- bridges/TwitterBridge.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bridges/TwitterBridge.php b/bridges/TwitterBridge.php index 87757074..e9728f96 100644 --- a/bridges/TwitterBridge.php +++ b/bridges/TwitterBridge.php @@ -416,10 +416,11 @@ EOD; // Get a guest token. This is different to an API key, // and it seems to change more regularly than the API key. private function getGuestToken() { - $pageContent = getContents('https://twitter.com'); + $pageContent = getContents('https://twitter.com', array(), array(), true); $guestTokenRegex = '/gt=([0-9]*)/m'; - preg_match_all($guestTokenRegex, $pageContent, $guestTokenMatches, PREG_SET_ORDER, 0); + preg_match_all($guestTokenRegex, $pageContent['header'], $guestTokenMatches, PREG_SET_ORDER, 0); + if (!$guestTokenMatches) returnServerError('Could not parse guest token'); $guestToken = $guestTokenMatches[0][1]; return $guestToken; }