PHP code example of brunoinds / link-preview-detector
1. Go to this page and download the library: Download brunoinds/link-preview-detector 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/ */
brunoinds / link-preview-detector example snippets
use Brunoinds\LinkPreviewDetector\LinkPreviewDetector;
$response = LinkPreviewDetector::isForLinkPreview();
//returns a boolean (true/false). If it is true, it means the request is coming from a link preview crawler.
use Brunoinds\LinkPreviewDetector\LinkPreviewDetector;
$userAgent = $_SERVER['HTTP_USER_AGENT'];
$response = LinkPreviewDetector::isForLinkPreviewUserAgent($userAgent);
use Brunoinds\LinkPreviewDetector\LinkPreviewDetector;
$isForLinkPreview = LinkPreviewDetector::isForLinkPreview();
if ($isForLinkPreview)
{
echo '<meta property="og:title" content="Your Website Title" />';
echo '<meta property="og:description" content="Your Website Description" />';
echo '<meta property="og:image" content="URL to the image" />';
echo '<meta property="og:url" content="URL to your website" />';
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.