Posted By

Maximus1983 on 05/17/12


Tagged

php screen screenshots grab grabzit


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

Maximus1983
tux-world
Priestd09


Capture Screenshots in PHP


 / Published in: PHP
 

URL: http://grabz.it/api/php

Capture Web Screenshots easily with the GrabzIt PHP API

You will need the free GrabzIt Code Library to get started.

  1. /*
  2.  * The PHP file that takes the picture
  3. */
  4.  
  5. include("GrabzItClient.class.php");
  6.  
  7. //Create the GrabzItClient class
  8. //Replace "APPLICATION KEY", "APPLICATION SECRET" with the values from your account!
  9. $grabzIt = new GrabzItClient("APPLICATION KEY", "APPLICATION SECRET");
  10. //Take the picture the method will return the unique identifier assigned to this task
  11. $id = $grabzIt->TakePicture("http://www.google.com", "http://www.example.com/GrabzItHandler.php");
  12.  
  13. /*
  14.  * The GrabzItHandler file that saves the picture
  15. */
  16.  
  17. include("GrabzItClient.class.php");
  18.  
  19. $message = $_GET["message"];
  20. $customId = $_GET["customid"];
  21. $id = $_GET["id"];
  22. $filename = $_GET["filename"];
  23.  
  24. //Custom id can be used to store user ids or whatever is needed for the later processing of the
  25. //resulting screenshot
  26.  
  27. $grabzIt = new GrabzItClient("APPLICATION KEY", "APPLICATION SECRET");
  28. $result = $grabzIt->GetPicture($id);
  29.  
  30. if (!$result)
  31. {
  32. return;
  33. }
  34.  
  35. //Ensure that the application has the correct rights for this directory.
  36. file_put_contents("images" . DIRECTORY_SEPARATOR . $filename, $result);

Report this snippet  

You need to login to post a comment.