I want to implement dynamic twitter meta tag. So Every page when i try to share twitter will have their each specify image and title.
i tried set dynamic title, and image but it doesnt work. image and title didnt change dynamic.
I use this code to get data from database
include_once("../classes/viral.php");
$viral = new Viral();
$id = $viral->escape_string($_GET['id']);
$result = $viral->getData("SELECT * FROM preview WHERE id=$id");
foreach ($result as $res) {
$title = $res['title'];
$promoted = $res['promoted'];
$photo = $res['file'];
}
below twitter meta tag which i tried to use
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="<?php echo (($title == "" || $title == NULL) ? "My website" : $title) ?>"/>
<meta name="twitter:description" content="My description">
<meta name="twitter:image" content="<?php echo (($photo == "" || $photo == NULL) ? "upload/default-640.png" : $photo) ?>" />
Is it need specify size and resolution for image ?
Any missing code ?