Call Snapshot Site with HttpClient
The service sends the documented authentication header and fails explicitly on a non-success response.
use Symfony\Contracts\HttpClient\HttpClientInterface;
final class SnapshotClient
{
public function __construct(
private HttpClientInterface $http,
private string $apiKey,
) {}
public function capture(string $url): array
{
$response = $this->http->request('POST',
'https://api.prod.ss.snapshot-site.com/api/v1/screenshot',
[
'headers' => [
'x-snapshotsiteapi-key' => $this->apiKey,
],
'json' => [
'url' => $url,
'format' => 'webp',
'width' => 1440,
'height' => 900,
'fullSize' => true,
],
]
);
return $response->toArray();
}
}
