Take Website Screenshots with PHP
The best way to put website screenshots into your PHP application is by downloading our simple to use PHP package.
GrabzIt's screenshot API is very flexible and can be called in many ways such as from a cronjob or a PHP web page.
First of all create an instance of the GrabzItClient class. Pass your application key and application secret from your GrabzIt account to the constructor.
// Create the GrabzItClient class
// Replace "APPLICATION KEY", "APPLICATION SECRET" with the values from your account!
$grabzIt = new GrabzItClient("APPLICATION KEY", "APPLICATION SECRET");
Then use one of the SetImageOptions, SetPDFOptions or SetTableOptions methods to request that the GrabzIt service take a screenshot of the URL passed to it.
// To take a image screenshot
// Or to take a PDF screenshot
// Or to capture table(s)
Then use one of the following save methods. Notice that we also include the URL to the handler.php this handler will process the callback from the service and save the resulting screenshot.
Alternatively the synchonous SaveTo method, this will force your application to wait while the screenshot is created so it should only be used were the Save method cannot be used. Once the screenshot is created it is saved to the file path provided.
$filepath = "images/test.jpg";
There are many more options including; configuring the browser height, browser width, screenshot height, screenshot width, the delay before a screenshot is taken and the image format of the screenshot. For all these options please see the Client documentation.