previewlinks / laravel-previewlinks
The official Laravel client for PreviewLinks.io
Fund package maintenance!
larsklopstra
Requires
- php: ^8.0
- illuminate/contracts: ^8.73|^9.0|^10.0|^11.0
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- nunomaduro/collision: ^5.10|^6.0|^7.0
- nunomaduro/larastan: ^1.0
- orchestra/testbench: ^6.22|^7.0|^8.0|^9.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5|^10.0|^11.0
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2025-03-30 16:23:02 UTC
README
This is the official PreviewLinks client for Laravel.
Installation
You can install the package via Composer:
composer require previewlinks/laravel-previewlinks
Usage
Configuration
You can set an API token in your .env
by using PREVIEWLINKS_API_TOKEN
.
return [ /** * PreviewLinks API token * * Obtain one from https://previewlinks.io/app/account */ 'api_token' => env('PREVIEWLINKS_API_TOKEN'), ];
Methods
use PreviewLinks\PreviewLinks; /** @var PreviewLinks $previewlinks */ $previewlinks = app(PreviewLinks::class); $sites = $previewlinks->listSites(); $site = $previewlinks->showSite(siteId: 1); $siteTemplates = $previewlinks->listSiteTemplates(siteId: 1); // This will return a JSON response with the image URL, the request may take 4 to 8 seconds to complete $downloadableImageUrl = $previewlinks->downloadImage(siteId: 1, templateId: 1, fields: [ 'previewlinks:title' => 'Hello from Laravel', 'previewlinks:cta' => 'This is an example', ]); // This method makes no API requests, we advise to use this over `downloadImage` $signedImageUrl = $previewlinks->signedImageUrl(templateId: 1, [ 'previewlinks:title' => 'Hello from Laravel', 'previewlinks:cta' => 'This is an example', ]);
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.