PHP code example of hqapi / hqapi-client

1. Go to this page and download the library: Download hqapi/hqapi-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hqapi / hqapi-client example snippets




use HQAPI\ScreenshotClient;
use HQAPI\Exceptions\ApiException;


try {
    $response = $client->create(
        url: "https://hqapi.com/",
        theme: "dark",
        full_page: true
    );

    // Get raw content (image data)
    $imageData = $response->getContent();

    // Save to disk
    file_put_contents("screenshot.png", $imageData);

    echo "Screenshot saved successfully!";
} catch (ApiException $e) {
    echo "API error: " . $e->getMessage();
}

use HQAPI\ExampleClient;

$example = new ExampleClient('YOUR_API_TOKEN_HERE');

try {
    // No operation
    $nop = $example->nop();
    
    // Ping
    $ping = $example->ping("hello");
    
    // Add numbers
    $sum = $example->add(3, 7);
    
    echo "Ping response: $ping, Sum: $sum";
} catch (ApiException $e) {
    echo "API error: " . $e->getMessage();
}