There are two methods that can be used to retrieve screenshots, table captures and animated GIF's from GrabzIt's API, both of which have their own advantages and disadvantages.
Also known as the callback method, this the recommended way to retrieve captures. However it does require the application being built to have a domain name or publicly available IP address. One example were this method could be used would be a web application.
As can be seen in the diagram the Asynchronous Method works by sending a call to GrabzIt and then waiting for a call being sent back to the application stating that the screenshot is ready. The advantage of using this method is that it requires fewer calls and allows other processes, such as a web requests to proceed uninterrupted.
An example of a asynchronous call is shown below for every server side language GrabzIt currently supports.
Remember that in order to call GrabzIt's API asynchronously you will need to implement this ASP.NET handler.
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); grabzIt.URLToImage("http://www.spacex.com"); grabzIt.Save("http://www.mywebsite.com/Home/Handler");
Remember that in order to call GrabzIt's API asynchronously you will need to implement this Java handler.
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); grabzIt.URLToImage("http://www.spacex.com"); grabzIt.Save("http://www.mywebsite.com/handler");
Remember that in order to call GrabzIt's API asynchronously you will need to implement this Node.js handler, however this should not be confused with the Node.js function callbacks. The callbacks discussed here are HTTP callbacks sent over the Internet!
var grabzit = require('grabzit'); var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret"); client.url_to_image("http://www.spacex.com"); client.save("http://www.example.com/handler", function (error, id){ if (error != null){ throw error; } });
Remember that in order to call GrabzIt's API asynchronously you will need to implement this Perl handler.
$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret"); $grabzIt->URLToImage("http://www.spacex.com"); $grabzIt->Save("http://www.mywebsite.com/handler.pl");
Remember that in order to call GrabzIt's API asynchronously you will need to implement this PHP handler.
$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); $grabzIt->URLToImage("http://www.spacex.com"); $grabzIt->Save("http://www.mywebsite.com/handler.php");
Remember that in order to call GrabzIt's API asynchronously you will need to implement this Python handler.
grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret") grabzIt.URLToImage("http://www.spacex.com") grabzIt.Save("http://www.mywebsite.com/handler.py")
Remember that in order to call GrabzIt's API asynchronously you will need to implement this Ruby handler.
grabzIt = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret") grabzIt.url_to_image("http://www.spacex.com") grabzIt.save("http://www.mywebsite.com/handler/index")
This method should only be used were it is not possible to use the Asynchronous Method. The Synchronous Method works by sending a call to GrabzIt to create the capture, then polling GrabzIt every few seconds until it's ready, as shown in the diagram.
Once ready it downloads the capture as usual. The disadvantage of this technique is that it forces the current process to wait until the capture is complete, which is why it is not appropriate for web applications. However the advantage is that the application does not need a domain name or IP address and so can be used from desktop applications.
An example of a synchronous call being made is shown below for every server side language GrabzIt currently supports.
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); grabzIt.URLToImage("http://www.spacex.com"); grabzIt.SaveTo("spacex.jpg");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); grabzIt.URLToImage("http://www.spacex.com"); grabzIt.SaveTo("spacex.jpg");
<script src="https://cdn.jsdelivr.net/npm/@grabzit/js@3.5.2/grabzit.min.js"></script>
<script>
GrabzIt("Sign in to view your Application Key").ConvertURL("http://www.spacex.com").Create();
</script>
var grabzit = require('grabzit'); var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret"); client.url_to_image("http://www.spacex.com"); client.save_to("spacex.jpg", function (error, id){ if (error != null){ throw error; } });
$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret"); $grabzIt->URLToImage("http://www.spacex.com"); $grabzIt->SaveTo("spacex.jpg");
$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); $grabzIt->URLToImage("http://www.spacex.com"); $grabzIt->SaveTo("spacex.jpg");
grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret") grabzIt.URLToImage("http://www.spacex.com") grabzIt.SaveTo("spacex.jpg")
grabzIt = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret") grabzIt.url_to_image("http://www.spacex.com") grabzIt.save_to("spacex.jpg")