1. Go to this page and download the library: Download screenshotscout/sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
screenshotscout / sdk example snippets
declare(strict_types=1);
use ScreenshotScout\BinaryCaptureResponse;
use ScreenshotScout\CaptureOptions;
use ScreenshotScout\Client;
ithFullPage(true),
);
if (!$response instanceof BinaryCaptureResponse) {
throw new RuntimeException('Expected a binary response.');
}
file_put_contents('screenshot.png', $response->bytes());
echo ($response->screenshotUrl() ?? 'No screenshot URL returned') . PHP_EOL;
declare(strict_types=1);
use ScreenshotScout\CaptureOptions;
use ScreenshotScout\CaptureResponseType;
use ScreenshotScout\Client;
use ScreenshotScout\JsonCaptureResponse;
ON),
);
if (!$response instanceof JsonCaptureResponse) {
throw new RuntimeException('Expected a JSON response.');
}
echo ($response->result()->screenshotUrl() ?? 'No screenshot URL returned') . PHP_EOL;
declare(strict_types=1);
use ScreenshotScout\BinaryCaptureResponse;
use ScreenshotScout\CaptureFormat;
use ScreenshotScout\CaptureHttpMethod;
use ScreenshotScout\CaptureOptions;
use ScreenshotScout\Client;
CaptureHttpMethod::GET,
);
if (!$response instanceof BinaryCaptureResponse) {
throw new RuntimeException('Expected a binary response.');
}
file_put_contents('screenshot.webp', $response->bytes());
declare(strict_types=1);
use ScreenshotScout\CaptureOptions;
use ScreenshotScout\Client;
aptureUrl = $client->buildCaptureUrl(
'https://example.com',
(new CaptureOptions())
->withFullPage(true)
->withBlockAds(true),
);
echo $captureUrl . PHP_EOL;
declare(strict_types=1);
use GuzzleHttp\Client as GuzzleClient;
use ScreenshotScout\BinaryCaptureResponse;
use ScreenshotScout\CaptureOptions;
use ScreenshotScout\Client;
w CaptureOptions())->withTimeout(180),
);
if (!$response instanceof BinaryCaptureResponse) {
throw new RuntimeException('Expected a binary response.');
}
file_put_contents('screenshot.png', $response->bytes());
declare(strict_types=1);
use ScreenshotScout\Client;
use ScreenshotScout\Exception\ApiException;
use ScreenshotScout\Exception\ConfigurationException;
use ScreenshotScout\Exception\ResponseDecodingException;
use ScreenshotScout\Exception\SerializationException;
use ScreenshotScout\Exception\TransportException;
rs(), $exception->responseBody());
echo $exception->rawResponse()->body();
} catch (TransportException $exception) {
var_dump($exception->getPrevious());
} catch (ConfigurationException|SerializationException|ResponseDecodingException $exception) {
echo $exception->getMessage();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.