Capture a product page from WordPress
This server-side request keeps the key out of the storefront and checks the WordPress transport result.
$response = wp_remote_post(
'https://api.prod.ss.snapshot-site.com/api/v1/screenshot',
[
'timeout' => 45,
'headers' => [
'Content-Type' => 'application/json',
'x-snapshotsiteapi-key' => getenv('SNAPSHOT_SITE_API_KEY'),
],
'body' => wp_json_encode([
'url' => get_permalink($product_id),
'format' => 'webp',
'width' => 1440,
'height' => 900,
'fullSize' => true,
'hideCookie' => true,
]),
]
);
if (is_wp_error($response)) {
throw new RuntimeException($response->get_error_message());
}
