1. Go to this page and download the library: Download propay/link-preview 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/ */
propay / link-preview example snippets
use Propay\LinkPreview\Client;
$previewClient = new Client('https://www.boogiecall.com/en/Melbourne');
// Get previews from all available parsers
$previews = $previewClient->getPreviews();
// Get a preview from specific parser
$preview = $previewClient->getPreview('general');
// Convert output to array
$preview = $preview->toArray();
// Default connect timeout is 5 seconds, you can change it to anything you want
$previewClient->getParser('general')->getReader()->config(['connect_timeout' => 3.14]);
// Default maximum redirect count is 10, but you can change it too
$previewClient->getParser('general')->getReader()->config(['allow_redirects' => ['max' => 10]]);
// If there is a network error (DNS, connect, etc), we throw ConnectionErrorException
try {
$previews = $previewClient->getPreviews();
} catch (\Propay\LinkPreview\Exceptions\ConnectionErrorException $e) {
echo "Oh no!";
}
use Propay\LinkPreview\Client;
$previewClient = new LinkPreview('https://www.youtube.com/watch?v=v1uKhwN6FtA');
// Only parse YouTube specific information
$preview = $previewClient->getPreview('youtube');
var_dump($preview->toArray());
// Add in your config/app.php
'providers' => [
'...',
'Propay\LinkPreview\Integrations\LaravelServiceProvider',
];
'aliases' => [
'...',
'Preview' => 'Propay\LinkPreview\Integrations\LaravelFacade',
];
// Set target url
Preview::setUrl('https://www.boogiecall.com');
// Get parsed HTML tags as a plain array
Preview::getPreview('general')->toArray();
// In case of redirects, see what the final url was
echo Preview::getUrl();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.