You can easily integrate PreviewLinks with your Laravel application, simply install the package composer require previewlinks/laravel-previewlinks
, obtain an API token and add it to your .env
.
# .env
PREVIEWLINKS_API_TOKEN=<YOUR_API_TOKEN>
// web.php
Route::get('/example', function() {
$image = app(\PreviewLinks\PreviewLinks::class)->signedImageUrl(templateId: 1, fields: [
'previewlinks:title' => 'Hello from Laravel',
'previewlinks:cta' => 'Get Started',
]);
return view('example', [
'image' => $image,
]);
});
// example.blade.php
<meta property="og:image" content="{{ $image }}" />
<meta name="twitter:image" content="{{ $image }}" />