PHP code example of flashcapture / client

1. Go to this page and download the library: Download flashcapture/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/ */

    

flashcapture / client example snippets




use FlashCapture\Client;

$flash = new Client('YOUR_RAPID_API_KEY');

try {
    // One-liner: Capture and save to disk
    $flash->captureAndSave(
        'https://laravel.com', 
        __DIR__ . '/laravel.png',
        [
            'fullPage' => true,
            'darkMode' => true,
            'width' => 1920
        ]
    );
    
    echo "Snapshot saved!";

} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}


public function store(Request $request)
{
    $client = new \FlashCapture\Client(env('RAPID_API_KEY'));
    
    // Start the job asynchronously
    $jobId = $client->capture($request->input('url'));
    
    // Dispatch a Laravel Job to check status later
    CheckScreenshotStatus::dispatch($jobId)->delay(now()->addSeconds(5));
    
    return response()->json(['job_id' => $jobId]);
}