PHP code example of previewlinks / php-previewlinks

1. Go to this page and download the library: Download previewlinks/php-previewlinks 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/ */

    

previewlinks / php-previewlinks example snippets




use PreviewLinks\PreviewLinks;

$previewlinks = new PreviewLinks('<YOUR_SITE_API_KEY>');

$response = $previewlinks->image(
    templateId: 1,
    fields: [
        'previewlinks:title' => 'Hello from PHP SDK',
    ],
);

// `$response` will return the response object
// Be aware that you have to handle any errors or exceptions
$url = $response->toArray(throw: false)['url'];



use PreviewLinks\PreviewLinks;

$previewlinks = new PreviewLinks('<YOUR_SITE_API_KEY>');

$url = $previewlinks->asyncImage(
    templateId: 1,
    fields: [
        'previewlinks:title' => 'Hello from PHP SDK',
    ],
);

// <meta name="twitter:image" content="{{ $url }}" >
bash
composer