capture-request.php 800 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. require '../vendor/autoload.php';
  3. use JonnyW\PhantomJs\Client;
  4. $client = Client::getInstance();
  5. $request = $client->getMessageFactory()->createCaptureRequest();
  6. $response = $client->getMessageFactory()->createResponse();
  7. $top = 10;
  8. $left = 10;
  9. $width = 200;
  10. $height = 400;
  11. $request->setMethod('GET');
  12. $request->setUrl('http://google.com');
  13. $request->setCaptureFile(sprintf('%s/file.jpg', sys_get_temp_dir()));
  14. $request->setCaptureDimensions($width, $height, $top, $left);
  15. $client->send($request, $response);
  16. var_dump($response);
  17. // If the capture dimensions were applied
  18. // to the request, you will see an information
  19. // notice in the debug log. This is useful for
  20. // debugging captures and will always be present,
  21. // even if debug mode is disabled.
  22. var_dump($client->getLog());