$params = http_build_query(array(
"access_key" => "YOUR_API_KEY",
"url" => "https://example.com",
"width" => 1200,
"height" => "600",
"cache": 3600
));
$image_data = file_get_contents("https://api.snapapi.ru/api/v1/screenshot?" . $params);
file_put_contents("screenshot.jpeg", $image_data);
;
from urllib.parse import urlencode
from urllib.request import urlretrieve
params = urlencode(
dict(
access_key="YOUR_API_KEY",
url="https://example.com",
"width": 1200,
"height": "600",
"cache": 3600
)
)
urlretrieve("https://api.snapapi.ru/api/v1/screenshot?" + params, "screenshot.jpeg")
const https = require('https');
const fs = require('fs');
https.get("https://api.snapapi.ru/api/v1/screenshot?" + new URLSearchParams({
access_key: "YOUR_API_KEY",
url: "https://example.com",
"width": 1200,
"height": "600",
"cache": 3600
}).toString(), (response) => {
response.pipe(fs.createWriteStream('screenshot.jpeg'));
});
package main
import (
"io"
"net/http"
"os"
)
func main() {
snapAPIEndpoint := "https://api.snapapi.ru/api/v1/screenshot"
request, _ := http.NewRequest("GET", snapAPIEndpoint, nil)
query := request.URL.Query()
query.Add("access_key", "YOUR_API_KEY")
query.Add("url", "https://example.com")
query.Add("width", "1200")
query.Add("height", "600")
query.Add("cache", "3600")
request.URL.RawQuery = query.Encode()
client := &http.Client{}
response, _ := client.Do(request)
defer response.Body.Close()
image, _ := os.Create("screenshot.jpeg")
io.Copy(image, response.Body)
image.Close()
}
using System.Net;
public class SnapAPIExample
{
private const string SnapAPIEndpoint = "https://api.snapapi.ru/api/v1/screenshot";
public static void Main ()
{
using(var webClient = new WebClient())
{
// The System.Web assembly reference is required.
var parameters = System.Web.HttpUtility.ParseQueryString(string.Empty);
parameters["access_key"] = "YOUR_API_KEY";
parameters["url"] = "https://example.com";
parameters["width"] = "1200";
parameters["height"] = "600";
parameters["cache"] = "3600";
webClient.DownloadFile(SnapAPIEndpoint + "?" + parameters, "screenshot.jpeg");
}
}
}
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
public class Main {
private static String ACCESS_KEY = "YOUR_API_KEY";
private static String SNAPAPI_ENDPOINT = "https://api.snapapi.ru/api/v1/screenshot";
public static void main(String[] args) throws Exception {
String params = String.format("?access_key=%s&url=https://example.com", ACCESS_KEY);
URL apiCallUrl = new URL(SNAPAPI_ENDPOINT + params);
InputStream inputStream = apiCallUrl.openStream();
OutputStream outputStream = new FileOutputStream("screenshot.jpeg");
byte[] b = new byte[2048];
int length;
while ((length = inputStream.read(b)) != -1) {
outputStream.write(b, 0, length);
}
inputStream.close();
outputStream.close();
}
}
require "open-uri"
File.open('screenshot.jpeg', 'wb') do |fo|
params = URI.encode_www_form("access_key" => "YOUR_API_KEY",
"url" => "https://example.com")
fo.write open("https://api.snapapi.ru/api/v1/screenshot?" + params).read
end