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:
include("GrabzItClient.class.php"); //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("http://www.google.com", "http://www.example.com/GrabzItHandler.php");
Then you accept the resulting screenshot with code similar to this:
include("GrabzItClient.class.php"); $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) { return; } //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.