PHP code example of rishimohan / orshot
1. Go to this page and download the library: Download rishimohan/orshot 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/ */
rishimohan / orshot example snippets
rshot\Client;
$client = new Client("YOUR_ORSHOT_API_KEY");
$response = $client->renderFromStudioTemplate([
'templateId' => 1234,
'modifications' => [
'title' => 'Orshot Studio',
'description' => 'Generate images from custom templates',
],
'response' => [ 'type' => 'url', 'format' => 'png', 'scale' => 2 ],
]);
$response = $client->renderFromStudioTemplate([
'templateId' => 1234,
'modifications' => [ 'title' => 'Invoice #1234' ],
'response' => [ 'type' => 'url', 'format' => 'pdf' ],
'pdfOptions' => [
'margin' => '20px',
'rangeFrom' => 1,
'rangeTo' => 2,
'colorMode' => 'rgb',
'dpi' => 300,
],
]);
$response = $client->renderFromStudioTemplate([
'templateId' => 1234,
'modifications' => [
'videoElement' => 'https://example.com/custom-video.mp4',
'videoElement.trimStart' => 0,
'videoElement.trimEnd' => 10,
],
'response' => [ 'type' => 'url', 'format' => 'mp4' ],
'videoOptions' => [ 'trimStart' => 0, 'trimEnd' => 20, 'muted' => false, 'loop' => true ],
]);
$response = $client->renderFromStudioTemplate([
'templateId' => 1234,
'modifications' => [ 'title' => 'Check out our latest update!' ],
'response' => [ 'type' => 'url', 'format' => 'png' ],
'publish' => [
'accounts' => [1, 2],
'content' => 'Check out our latest design!',
],
]);
// $response['publish'] => [['platform' => 'twitter', 'username' => 'acmehq', 'status' => 'published'], ...]
$response = $client->renderFromStudioTemplate([
'templateId' => 1234,
'modifications' => [ 'title' => 'Scheduled post' ],
'response' => [ 'type' => 'url', 'format' => 'png' ],
'publish' => [
'accounts' => [1],
'content' => 'This will be posted later!',
'schedule' => [ 'scheduledFor' => '2026-04-01T10:00:00Z' ],
'timezone' => 'America/New_York',
],
]);
$response = $client->renderFromTemplate([
'templateId' => 'open-graph-image-1',
'modifications' => [ 'title' => 'Hello World' ],
'responseType' => 'url',
'responseFormat' => 'png',
]);
$response = $client->generateSignedUrl([
'templateId' => 'open-graph-image-1',
'modifications' => [ 'title' => 'Hello World' ],
'expiresAt' => 1744276943,
'renderType' => 'images',
'responseFormat' => 'png',
]);