Get a Free Trial

Capture Websites with our PHP Screenshot API

DownloadTechnical Information
PHP API
The diagnostics panel can help you debug your code!

GrabzIt's free website screenshot API offers great flexibility and users can utilize it in various ways. For instance, by calling it from a cronjob or a PHP application. To add website screenshots or HTML to image features to your PHP app, follow these steps for the best results:

  1. Get your free key and secret.
  2. Download the free PHP Library and try out the demo app.
  3. Learn the basics about how GrabzIt's API works. By reading the overview below.

PHP API Overview

To use our screenshot service you will first need to create an instance of the GrabzItClient class. Then pass your application key and application secret from your to the constructor.

include("GrabzItClient.php");

// Create the GrabzItClient class
// Replace "APPLICATION KEY", "APPLICATION SECRET" with the values from your account!
$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

Then use one of the DOCX, image, PDF, animation or table options. To capture a URL or convert HTML.

// To take a image screenshot
$grabzIt->URLToImage("https://www.tesla.com"); 	
// Or to take a PDF screenshot
$grabzIt->URLToPDF("https://www.tesla.com");
// Or to convert online videos into animated GIF's
$grabzIt->URLToAnimation("http://www.example.com/video.avi");
// Or to capture table(s)
$grabzIt->URLToTable("https://www.tesla.com");
// To convert HTML into a image
$grabzIt->HTMLToImage("<html><body><h1>Hello World!</h1></body></html>"); 	
// Or convert HTML into a PDF document
$grabzIt->HTMLToPDF("<html><body><h1>Hello World!</h1></body></html>");
// Or convert HTML into a CSV, XLSX or JSON document
$grabzIt->HTMLToTable("<html><body><table><tr><th>Name</th><th>Age</th></tr>
    <tr><td>Tom</td><td>23</td></tr><tr><td>Nicola</td><td>26</td></tr>
    </table></body></html>");
// To convert HTML file into a image
$grabzIt->FileToImage("example.html"); 	
// Or convert HTML file into a PDF document
$grabzIt->FileToPDF("example.html");
// Or convert HTML file into a CSV, XLSX or JSON document
$grabzIt->FileToTable("tables.html");

Next use one of the following save methods. With the Save method, you specify the URL to the handler.php. This handler will process the callback from the service and save the resulting screenshot.

$grabzIt->Save("http://www.example.com/handler.php"); 	
Always use the SaveTo method on localhost

If a publicly accessible callback handler is not available, use the synchronous SaveTo method instead.

This will make your application wait until it creates the screenshot. So you should only use it where the Save method is not appropriate. Once GrabzIt creates the screenshot, it automatically saved to the specified file path.

$filepath = "images/result.jpg";
$grabzIt->SaveTo($filepath);

More Options

When creating screenshots or converting HTML there are many more advanced options. Including: full page screenshots, configuring the browser width and height, image width and height. Or to specify a delay before creating a capture and select the image format of the screenshot.

GrabzIt also supports creating other file formats such as PDFs, DOCX, Animated GIFs, CSVs, and more. For all these options please see the Client documentation. There are also more advanced examples available.