Download the PHP package screenshotscout/sdk without Composer
On this page you can find all versions of the php package screenshotscout/sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download screenshotscout/sdk
More information about screenshotscout/sdk
Files in screenshotscout/sdk
Package sdk
Short Description Official PHP SDK for the Screenshot Scout screenshot API.
License MIT
Homepage https://screenshotscout.com
Informations about the package sdk
Screenshot Scout PHP SDK
The official PHP SDK for the Screenshot Scout screenshot API.
capture() sends a screenshot request and waits until the result is ready.
Requirements
- PHP 8.3 or newer
Installation
Install the SDK with Composer:
Get your API credentials
Sign up for Screenshot Scout or sign in, then copy the access key and secret key from the API Keys page. The access key is required. The secret key is optional and enables signed requests.
Capture a screenshot
Pass the page URL and any capture settings to capture(). This example captures the full page and
saves the returned image:
POST is used by default. capture() returns a BinaryCaptureResponse unless JSON is requested.
Use bytes() to access the screenshot or PDF contents.
Request a JSON result
Set the response type to JSON when you want capture metadata instead of image or PDF bytes:
Use GET
Pass CaptureHttpMethod::GET as the third argument. POST remains the default.
Build a capture URL
buildCaptureUrl() creates a capture URL without sending a request. It accepts the same
CaptureOptions as capture():
Generated capture URLs contain your access key, so treat them as sensitive. A configured secret key signs them automatically. Before sharing generated URLs, enable Require signed requests on the API Keys page.
Signed requests
Pass the API key's secret as the optional secretKey constructor argument. The client then signs
generated capture URLs and GET requests automatically. The secret key is never transmitted. POST
requests can't be signed, so capture with CaptureHttpMethod::GET, as in Use GET. See
the signed requests guide.
Capture options
CaptureOptions is immutable: each with...() method returns a changed copy. Available options
include:
- Output:
withFormat,withResponseType - Network and location:
withCountry,withProxy,withGeolocationLatitude,withGeolocationLongitude,withGeolocationAccuracy - Cookies and webpage headers:
withCookies,withHeaders - Timing:
withTimeout,withWaitUntil,withNavigationTimeout,withDelay - Device emulation:
withDevice,withDeviceViewportWidth,withDeviceViewportHeight,withDeviceScaleFactor,withDeviceIsMobile,withDeviceHasTouch,withDeviceUserAgent - Page behavior:
withTimezone,withMediaType,withColorScheme,withReducedMotion - Full page:
withFullPage,withFullPagePreScroll,withFullPagePreScrollStep,withFullPagePreScrollStepDelay,withFullPageMaxHeight - Blocking:
withBlockCookieBanners,withBlockAds,withBlockChatWidgets - DOM changes:
withHideSelectors,withClickSelectors,withClickAllSelectors,withInjectCss,withInjectJs,withBypassCsp - Framing:
withSelector,withClipX,withClipY,withClipWidth,withClipHeight - Image output:
withImageWidth,withImageHeight,withImageMode,withImageAnchor,withImageAllowUpscale,withImageBackground,withImageQuality - PDF:
withPdfPaperFormat,withPdfLandscape,withPdfPrintBackground,withPdfMargin,withPdfMarginTop,withPdfMarginRight,withPdfMarginBottom,withPdfMarginLeft,withPdfScale,withPdfPageRanges - Caching:
withCache,withCacheTtl,withCacheKey - Storage:
withStorageMode,withStorageEndpoint,withStorageBucket,withStorageRegion,withStorageObjectKey
Use CaptureFormat, CaptureResponseType, CaptureWaitUntil, CaptureMediaType,
CaptureColorScheme, CaptureImageMode, CaptureImageAnchor, CapturePdfPaperFormat, and
CaptureStorageMode for documented values. The corresponding methods also accept strings. See the
Screenshot Scout option reference for
allowed values and behavior.
HTTP timeouts and customization
withTimeout() controls how long Screenshot Scout may spend capturing the page. It does not set the
PHP HTTP timeout. To configure the HTTP timeout, pass a custom PSR-18 client:
The default HTTP client has no total request timeout. Without PHP's cURL extension, it waits up to 300 seconds for a response. A custom client can also configure proxies, TLS, and other HTTP settings.
Raw responses and errors
Use rawResponse() to access the status, headers, content type, and response body. ApiException
also provides the underlying response.
All SDK exceptions implement ScreenshotScout\Exception\ScreenshotScoutException, which can be
caught to handle any SDK error. TransportException::getPrevious() returns the underlying HTTP
client exception.
License
Licensed under the MIT License.
All versions of sdk with dependencies
guzzlehttp/psr7 Version ^2.13
php Version >=8.3
psr/http-client Version ^1.0
psr/http-message Version ^1.1 || ^2.0