PHP code example of heroshots / sdk

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

    

heroshots / sdk example snippets


use HeroShots\Client;

// Email/password login: stores the JWT, auto re-logins on expiry.
// Base URL defaults to https://app.heroshots.ai.
$client = Client::fromLogin('[email protected]', 'secret');

// Or reuse an existing token.
$client = new Client(token: 'eyJ...');

use HeroShots\Client;

$client = new Client(token: 'lz_live_YOUR_AGENCY_KEY', managedUserId: 12345);
$job = $client->images->generate('https://example.com/product.jpg');

// Switch target brand later, or pass null to clear it.
$client->withManagedUser(67890);

// Local file paths are auto-uploaded to hosted URLs.
$briefs = $client->storyboard->briefSuggestions('product.jpg', 'model.jpg', [
    'duration_seconds' => 30, 'language_code' => 'it',
]);

$candidates = $client->storyboard->candidates($briefs[0], 30, 'product.jpg', 'model.jpg');

$job = $client->storyboard->generate($briefs[0], 30, $candidates[0], 'product.jpg', 'model.jpg');
$sb  = $client->storyboard->wait($job['job_id']);          // polls until done/failed

$vjob  = $client->longvideo->start('product.jpg', null, $sb['storyboard']);
$final = $client->longvideo->wait($vjob['job_id']);
echo $final['final_video_url'];

use HeroShots\Errors\ValidationException;

try {
    $client->storyboard->candidates('', 30, 'p.jpg');
} catch (ValidationException $e) {
    echo $e->errorCode . ': ' . $e->getMessage();
}