url2screen API

Demonstration



Endpoint

POST https://api.igt.com.hk/url2screen/v1

Parameters

Parameter Type Description
api_key string Your API key for authentication
fullscreen integer (1 or 0) Specify if the screenshot should be fullscreen (1) or not (0)
delay integer Specify the delay of the capture action in second. Default as 2 seconds delay for capturing the screen in order to prevent some loading didn't finished.
width integer (Optional) The width of the screenshot in pixels
height integer (Optional) The height of the screenshot in pixels

Response

The API will return a JSON response with the following structure:

{
  "image_link": "https://api.igt.com.hk/frontend/url2screen/v1/screenshot.jpg"
}

Example Usage (PHP)

<?php
function callUrl2ScreenAPI($apiKey, $url) {
    $endpoint = 'https://api.igt.com.hk/url2screen/v1';

    // Prepare the data to be sent in the request body
    $data = array(
        'api_key' => $apiKey,
        'url' => $url
    );

    // Convert the data to JSON format
    $jsonData = json_encode($data);

    // Set the request headers
    $headers = array(
        'Content-Type: application/json',
        'Content-Length: ' . strlen($jsonData)
    );

    // Initialize cURL and set the options
    $ch = curl_init($endpoint);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
    curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

    // Execute the cURL request
    $response = curl_exec($ch);

    // Check for errors
    if ($response === false) {
        $error = curl_error($ch);
        curl_close($ch);
        return json_encode(array('error' => $error));
    }

    // Close the cURL session
    curl_close($ch);

    // Return the response
    return $response;
}

// Example usage
$apiKey = 'your_api_key';
$url = 'https://b123.be';

$response = callUrl2ScreenAPI($apiKey, $url);

// Output the response
echo $response;
?>