mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-03-14 20:21:14 +03:00
[TwitterBridge] Continue using existing guesttoken from cache, when requesting a new one failed (#2396)
This commit is contained in:
parent
8530aa54f2
commit
12ff697ab0
1 changed files with 11 additions and 3 deletions
|
@ -546,8 +546,16 @@ EOD;
|
|||
if($guestTokenUses === null || !is_array($guestTokenUses) || count($guestTokenUses) != 2
|
||||
|| $guestTokenUses[0] <= 0 || (time() - $refresh) > self::GUEST_TOKEN_EXPIRY) {
|
||||
$guestToken = $this->getGuestToken();
|
||||
$gt_cache->saveData(array(self::GUEST_TOKEN_USES, $guestToken));
|
||||
$r_cache->saveData(time());
|
||||
if ($guestToken === null) {
|
||||
if($guestTokenUses === null) {
|
||||
returnServerError('Could not parse guest token');
|
||||
} else {
|
||||
$guestToken = $guestTokenUses[1];
|
||||
}
|
||||
} else {
|
||||
$gt_cache->saveData(array(self::GUEST_TOKEN_USES, $guestToken));
|
||||
$r_cache->saveData(time());
|
||||
}
|
||||
} else {
|
||||
$guestTokenUses[0] -= 1;
|
||||
$gt_cache->saveData($guestTokenUses);
|
||||
|
@ -567,7 +575,7 @@ EOD;
|
|||
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) return null;
|
||||
$guestToken = $guestTokenMatches[0][1];
|
||||
return $guestToken;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue