mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-05 17:19:37 +00:00
[TwitterBridge] Continue using existing guesttoken from cache, when requesting a new one failed (#2396)
This commit is contained in:
parent
8530aa54f2
commit
12ff697ab0
@ -546,8 +546,16 @@ EOD;
|
|||||||
if($guestTokenUses === null || !is_array($guestTokenUses) || count($guestTokenUses) != 2
|
if($guestTokenUses === null || !is_array($guestTokenUses) || count($guestTokenUses) != 2
|
||||||
|| $guestTokenUses[0] <= 0 || (time() - $refresh) > self::GUEST_TOKEN_EXPIRY) {
|
|| $guestTokenUses[0] <= 0 || (time() - $refresh) > self::GUEST_TOKEN_EXPIRY) {
|
||||||
$guestToken = $this->getGuestToken();
|
$guestToken = $this->getGuestToken();
|
||||||
$gt_cache->saveData(array(self::GUEST_TOKEN_USES, $guestToken));
|
if ($guestToken === null) {
|
||||||
$r_cache->saveData(time());
|
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 {
|
} else {
|
||||||
$guestTokenUses[0] -= 1;
|
$guestTokenUses[0] -= 1;
|
||||||
$gt_cache->saveData($guestTokenUses);
|
$gt_cache->saveData($guestTokenUses);
|
||||||
@ -567,7 +575,7 @@ EOD;
|
|||||||
preg_match_all($guestTokenRegex, $pageContent['header'], $guestTokenMatches, PREG_SET_ORDER, 0);
|
preg_match_all($guestTokenRegex, $pageContent['header'], $guestTokenMatches, PREG_SET_ORDER, 0);
|
||||||
if (!$guestTokenMatches)
|
if (!$guestTokenMatches)
|
||||||
preg_match_all($guestTokenRegex, $pageContent['content'], $guestTokenMatches, PREG_SET_ORDER, 0);
|
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];
|
$guestToken = $guestTokenMatches[0][1];
|
||||||
return $guestToken;
|
return $guestToken;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user