PHP code example of lasselehtinen / issuu

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

    

lasselehtinen / issuu example snippets


use lasselehtinen\Issuu\Issuu;

$issuu = new Issuu('apiKey');
$drafts = new Drafts($issuu);

$body = [
    'confirmCopyright' => true,
    'fileUrl' => 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf',
    'info' => [
        'file' => 0,
        'access' => 'PUBLIC',
        'title' => 'Example title',
        'description' => 'Description',
        'preview' => false,
        'type' => 'editorial',
        'showDetectedLinks' => false,
        'downloadable' => false,
        'originalPublishDate' => '1970-01-01T00:00:00.000Z',
    ],
];

$createDraft = $drafts->create($body);

// Try few times until the file is converted
for ($i=0; $i < 10; $i++) {
    $draft = $drafts->getDraftBySlug($createDraft->slug);
    
    if ($draft->fileInfo->conversionStatus === 'DONE') {
        break;
    }

    sleep(2);
}

$publishDraftBySlug = $drafts->publishDraftBySlug($createDraft->slug, ['desiredName' => 'foobar']);