PHP

GitHub

//Webscreenshot.io
function webscreenshot_generate_image_url($url, $options){
	$api_key = 'YOURAPIKEY';
	$api_secret = 'YOURAPISECRET';
	$options['page'] = $url;
	$format = 'png';
	unset($options['format']);
	$optionParts = array();
	foreach ($options as $key => $values) {
	  $values = is_array($values) ? $values : array($values);
	  foreach ($values as $value) {
	    if(!empty($value)){
	      $encodedValue = rawurlencode($value);
	      $optionParts[] = htmlentities("$key=$encodedValue");
	    }
	  }
	}
	$queryString = implode("&", $optionParts);
	$generatedSecret = hash_hmac("sha256", $queryString, $api_secret);
	
	return "https://api.webscreenshot.io/v1/$api_key/$generatedSecret/$format?$queryString";
}


//Example Usage
$options['cache']     = 'true';
$options['height']  = '800';
$options['width']  = '800';
echo webscreenshot_generate_image_url("https://google.com", $options);