PHP - Capture screenshot of website from URL exampleBy Hardik Savani | September 12, 2016 | | 10283 Viewer| Category : PHP
Today, i am going to give you example of how to grab screen shot from given URL using PHP curl. There are several website provide API for capture website screenshot image using their API Secret and Key.
In this example i am using screenshotmachine.com website API. This website provide very simple way to user their API. If you haven't account on screenshotmachine.com then you must create new account and get Account Key. So you have to just copy that key.
I also use variable "$accountKey", you have to just assign that key on that variable. It is very simple example and using only simple file.
Make sure you have images folder in your root path with full permission. All images will download and store on that table.
<title>PHP - Capture screenshot of website from URL</title>
$image = time().'.png';
$accountKey = 'your Account Key';
$ch = curl_init('http://api.screenshotmachine.com/?key='.$accountKey.'&size=M&format=png&url='.$_GET['url']);
$fp = fopen('images/'.$image, 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
<img src="images/<?php echo $image ?>" />
You can get more information from here : Screenshotmachine.
- How to create snippets in sublime ?
- How to create custom scrollbar using jquery mcustomscrollbar plugin ?
- laravel 5 change date format using carbon example
- PHP - autocomplete websites with domain and logo using clearbit API
- Bootstrap SweetAlert - Confirm dialog box model with yes and no option example
- Laravel 5 - Paypal Payment Integration example using netshell/paypal package from scratch
- How to get current route name in Laravel 5?
- Bootstrap daterangepicker example code with demo using daterangepicker.js