capture-request.php 765 B

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