Get a Free Trial

Advanced Screenshot Features with PHP

DownloadTechnical Information
PHP API

GrabzIt's PHP API is highly customizable and is able to integrate tightly into your application. It exposes a lot of the inner workings of GrabzIt so you can customize how you use GrabzIt as much as possible. Two examples of this is checking the status of existing screenshots and setting the cookies that GrabzIt will use when taking screenshots or capturing content.

Screenshot Status

Use the GetStatus method to allow your app to check the status of a screenshot, perhaps to see if it is still processing or if it is cached and ready to be used.

$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

$status = $grabzIt.GetStatus(screenShotId);

if ($status->Processing)
{
    // screenshot has not yet been processed
}

if ($status->Cached)
{
    // screenshot is still cached by GrabzIt
}

if ($status->Expired)
{
    // screenshot is no longer on GrabzIt
    // Perhaps output status message?
    die $status->Message;
}

Cookies

Most websites use cookies to control functionality. To enable you to control this aspect of website functionality GrabzIt allows you to set your own custom cookies with the following cookie methods.

$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

// gets an array of cookies for google.com
$cookies = $grabzIt->GetCookies("google.com");

// sets a cookie for the google.com domain
$grabzIt->SetCookie("MyCookie", "google.com", "Any Value You Like");

// deletes the previously set cookie
$grabzIt->DeleteCookie("MyCookie", "google.com");

Display a Capture without Downloading

While we recommend that you download a capture to a web server before displaying it. You can also display any type of capture in a user's browser without downloading it onto your web server. However for this technique to work the user will have to wait for the capture to complete.

Once completed you can send the bytes of the capture returned by the SaveTo method to the response along with the correct mime type.

$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

$grabzIt->URLToImage("https://www.tesla.com");

header("Content-Type: image/jpeg");
echo $grabzIt->SaveTo();

As you can see in the above example there is no filename being passed to the SaveTo method which makes the method return the contents of the capture.

Other useful features include mobile screenshots and custom watermarks.