PHPBuilder - Capture Screenshots in PHP with GrabzIt

RSS Twitter

Capture Screenshots in PHP with GrabzIt

by: GrabzIt
May 24, 2012

GrabzIt has just launched their screenshot service, which allows developers to easily take screenshots of websites for free using the open source GrabzIt PHP Library. To take a screenshot with GrabzIt you first need to register to get your application key and secret, once done you will be up and running in no time.


You first request a screenshot with the following code:



//Create the GrabzItClient class
//Replace "APPLICATION KEY", "APPLICATION SECRET" with the values from your account!
$grabzIt = new GrabzItClient("APPLICATION KEY", "APPLICATION SECRET");
//Take the picture the method will return the unique identifier assigned to this task
$id = $grabzIt->TakePicture("", "");


Then you accept the resulting screenshot with code similar to this:



$message = $_GET["message"];
$customId = $_GET["customid"];
$id = $_GET["id"];
$filename = $_GET["filename"];

//Custom id can be used to store user ids or whatever is needed for the later processing of the
//resulting screenshot

$grabzIt = new GrabzItClient("APPLICATION KEY", "APPLICATION SECRET");
$result = $grabzIt->GetPicture($id);

if (!$result)

//Ensure that the application has the correct rights for this directory.
file_put_contents("images" . DIRECTORY_SEPARATOR . $filename, $result);


Remember to replace APPLICATION KEY and APPLICATION SECRET with your actual values.

Comment and Contribute

Your comment has been submitted and is pending approval.




(Maximum characters: 1200). You have characters left.