PHP
Signed URL
Generate signed URLs for on-demand image generation
generateImageSignedUrl
Generate a signed URL that can be used to generate images on-demand without making API calls. Perfect for dynamic content in emails, web pages, and more.
$signedUrl = $client->generateImageSignedUrl(
string $templateId,
array $options = []
)
Parameters
The template ID (e.g., ‘tpl_xxxxxxxxx’)
Optional configuration
Returns
Returns a signed URL string that can be used directly in HTML or shared.
string // e.g., "https://api.bannerify.co/v1/templates/signedurl?..."
Examples
Basic Signed URL
<?php
use Bannerify\Bannerify\BannerifyClient;
$client = new BannerifyClient('your-api-key');
$signedUrl = $client->generateImageSignedUrl('tpl_xxxxxxxxx');
echo "<img src='{$signedUrl}' alt='Generated Image' />";
With Modifications
$signedUrl = $client->generateImageSignedUrl('tpl_xxxxxxxxx', [
'modifications' => [
['name' => 'title', 'text' => 'Dynamic Title'],
['name' => 'subtitle', 'text' => 'Generated on the fly']
]
]);
echo "<img src='{$signedUrl}' alt='Dynamic Banner' />";
WebP Format
$signedUrl = $client->generateImageSignedUrl('tpl_xxxxxxxxx', [
'format' => 'webp',
'modifications' => [
['name' => 'title', 'text' => 'WebP Image']
]
]);
Bypass Cache
$signedUrl = $client->generateImageSignedUrl('tpl_xxxxxxxxx', [
'nocache' => true,
'modifications' => [
['name' => 'timestamp', 'text' => date('Y-m-d H:i:s')]
]
]);
Use Cases
Email Campaigns
Generate personalized images in emails:
$recipients = [
['name' => 'Alice', 'email' => '[email protected]'],
['name' => 'Bob', 'email' => '[email protected]'],
];
foreach ($recipients as $recipient) {
$signedUrl = $client->generateImageSignedUrl('tpl_email_header', [
'modifications' => [
['name' => 'name', 'text' => 'Hi, ' . $recipient['name'] . '!']
]
]);
$html = "<img src='{$signedUrl}' alt='Personalized Header' />";
// Send email with $html
}
Dynamic Open Graph Images
Generate OG images for social media sharing:
function getOgImageUrl($title, $author) {
global $client;
return $client->generateImageSignedUrl('tpl_og_image', [
'modifications' => [
['name' => 'title', 'text' => $title],
['name' => 'author', 'text' => $author]
]
]);
}
// In your HTML
$ogImage = getOgImageUrl('My Blog Post', 'John Doe');
echo "<meta property='og:image' content='{$ogImage}' />";
Real-time Analytics Badges
$stats = [
'views' => 1234,
'likes' => 567,
'shares' => 89
];
$badgeUrl = $client->generateImageSignedUrl('tpl_stats_badge', [
'modifications' => [
['name' => 'views', 'text' => (string)$stats['views']],
['name' => 'likes', 'text' => (string)$stats['likes']],
['name' => 'shares', 'text' => (string)$stats['shares']]
],
'nocache' => true
]);
echo "[](https://example.com)";
User Profile Cards
function generateProfileCard($userId, $name, $avatar) {
global $client;
return $client->generateImageSignedUrl('tpl_profile_card', [
'modifications' => [
['name' => 'user_name', 'text' => $name],
['name' => 'avatar', 'src' => $avatar],
['name' => 'user_id', 'text' => $userId]
]
]);
}
$profileUrl = generateProfileCard('123', 'Jane Smith', 'https://example.com/avatar.jpg');
Benefits
- No API Calls - Images are generated only when accessed
- CDN Caching - Subsequent requests are served from cache
- Security - URLs are signed and can’t be tampered with
- Flexibility - Perfect for emails, OG images, and dynamic content
- Cost Effective - Only generates when actually viewed