client = $client; $this->ogpResolver = $ogpResolver; } public function resolve(string $url): Metadata { $res = $this->client->get($url); if ($res->getStatusCode() === 200) { $metadata = $this->ogpResolver->parse($res->getBody()); parse_str(parse_url($metadata->image, PHP_URL_QUERY), $query); if(isset($query['token-time'])){ $expires_at_unixtime = $query['token-time']; $metadata->expires_at = Carbon::createFromTimestamp($expires_at_unixtime); } return $metadata; } else { throw new \RuntimeException("{$res->getStatusCode()}: $url"); } } }