Clearshot API screenshot tool

Take screenshots with PHP

using php to capture screenshots

Taking screenshots of a website or other URL with PHP is simple. Keeping framework agnostic, you can use a simple cURL request to easily receive a screenshot of any URL, with a range of options on resolution, sizing and response types. 

You will need a Clearshot access token which you can get here.

Next we pass the access token along with the target URL to Clearshot’s screenshot API endpoint.

For further documentation, parameters & error codes, check out the full documentation here.

 

				
					$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://app.clearshotapi.com/api/screenshot/",
  CURLOPT_HTTPHEADER =>
    array(
      "Authorization: Bearer [-- YOUR ACCESS TOKEN HERE --]",
      "Accept: application/json"
    ),
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => http_build_query(
    array(
      "url" => "https://apple.com",
      "json" => "true"
    )
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  $json_response = json_decode($response);
}
				
			
Share on whatsapp
Share on email
Share on linkedin
Share on facebook
Share on twitter