PHP code example of jorisvanw / cloudconvert-php
1. Go to this page and download the library: Download jorisvanw/cloudconvert-php 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/ */
jorisvanw / cloudconvert-php example snippets
CloudConvert\Api;
$api = new Api("your_api_key");
$api->convert([
'inputformat' => 'png',
'outputformat' => 'pdf',
'input' => 'upload',
'file' => fopen('./tests/input.png', 'r'),
])
->wait()
->download('./tests/output.pdf');
CloudConvert\Api;
$api = new Api("your_api_key");
//...
CloudConvert\Api;
$api = new Api("your_api_key");
$process = $api->createProcess([
'inputformat' => 'png',
'outputformat' => 'jpg',
]);
$process->start([
'outputformat' => 'jpg',
'converteroptions' => [
'quality' => 75,
],
'input' => 'download',
'file' => 'https://cloudconvert.com/blog/wp-content/themes/cloudconvert/img/logo_96x60.png',
'callback' => 'http://_INSERT_PUBLIC_URL_TO_/callback.php'
]);
echo "Conversion was started in background :-)";
CloudConvert\Api;
use \CloudConvert\Process;
$api = new Api("your_api_key");
$process = new Process($api, $_REQUEST['url']);
$process->refresh()->download("output.jpg");
CloudConvert\Api;
$api = new Api("your_api_key");
$process = $api->createProcess([
'inputformat' => 'png',
'outputformat' => 'jpg',
]);
$process->start([
'input' => 'upload',
'outputformat' => 'jpg',
'converteroptions' => [
'quality' => 75,
],
'callback' => 'http://_INSERT_PUBLIC_URL_TO_/callback.php'
]);
CloudConvert\Api;
$api = new Api("your_api_key");
$process = $api->convert([
'inputformat' => 'pdf',
'outputformat' => 'jpg',
'converteroptions' => [
'page_range' => '1-3',
],
'input' => 'download',
'file' => fopen('./tests/input.pdf', 'r'),
])
->wait()
->downloadAll('./tests/');
CloudConvert\Api;
$api = new Api("your_api_key");
try {
$api->convert([
'inputformat' => 'pdf',
'outputformat' => 'jpg',
'input' => 'upload',
'file' => fopen('./tests/input.pdf', 'r'),
])
->wait()
->downloadAll('./tests/');
} catch (\CloudConvert\Exceptions\ApiBadRequestException $e) {
echo "Something with your request is wrong: " . $e->getMessage();
} catch (\CloudConvert\Exceptions\ApiConversionFailedException $e) {
echo "Conversion failed, maybe because of a broken input file: " . $e->getMessage();
} catch (\CloudConvert\Exceptions\ApiTemporaryUnavailableException $e) {
echo "API temporary unavailable: " . $e->getMessage() ."\n";
echo "We should retry the conversion in " . $e->retryAfter . " seconds";
} catch (Exception $e) {
// network problems, etc..
echo "Something else went wrong: " . $e->getMessage() . "\n";
}