fix(cache): bug in prior refactor (#3525)

* fix(cache): bug in prior refactor

* yup
This commit is contained in:
Dag 2023-07-11 23:26:22 +02:00 committed by GitHub
parent b3bf95bfdd
commit 69aa751f40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,7 +12,7 @@ class TwitterClient
{
$this->cache = $cache;
$this->authorization = 'AAAAAAAAAAAAAAAAAAAAAGHtAgAAAAAA%2Bx7ILXNILCqkSGIzy6faIHZ9s3Q%3DQy97w6SIrzE7lQwPJEYQBsArEE2fC25caFwRBvAGi456G09vGR';
$this->data = $cache->loadData() ?? [];
$this->data = $this->cache->loadData() ?? [];
}
public function fetchUserTweets(string $screenName): \stdClass
@ -95,6 +95,9 @@ class TwitterClient
$response = getContents($url, $this->createHttpHeaders(), [CURLOPT_POST => true]);
$guest_token = json_decode($response)->guest_token;
$this->data['guest_token'] = $guest_token;
$this->cache->setScope('twitter');
$this->cache->setKey(['cache']);
$this->cache->saveData($this->data);
Logger::info("Fetch new guest token: $guest_token");
}
@ -119,6 +122,9 @@ class TwitterClient
}
$userInfo = $response->data->user;
$this->data[$screenName] = $userInfo;
$this->cache->setScope('twitter');
$this->cache->setKey(['cache']);
$this->cache->saveData($this->data);
return $userInfo;
}