【发布时间】:2020-07-14 16:47:53
【问题描述】:
我正在尝试将图像从数据库插入到推特卡(链接),但推文中出现的链接没有图像
推文卡片示例(链接)
尝试为推特卡制作默认图片,效果很好
但是当我尝试从数据库中检索图像的名称并将其放入 <meta> 时,它在 twitter 中显示为空图像
也尝试回显$picture,路径显示为它在数据库中:/image.png
<head>
<?php
//identify the user
$un = $_SESSION['active_user'];
//query to get that specific users information
$query = "SELECT * FROM users WHERE username='$un'";
//save the query in result variable
$result = $db->prepare($query);
//excecute the variable result
$result->execute();
//if the result has records in the database save the users info in the variables below
if ($row = $result->fetch())
{
//validation variables
$emptyFields = false;
$error = false;
$success = false;
$n = $row['name'];
$usn = $row['username'];
$picture=$row['picture'];
}
echo "<meta property='twitter:card' content='summary'>";
echo "<meta property='twitter:site' content=''>";
echo "<meta property='twitter:title' content=''>";
echo "<meta property='twitter:description' content=''>";
echo "<meta property='twitter:image' content='https://website.com/".$picture."'>";
echo "<meta name='twitter:creator' content='@abc'>";
echo "<meta name='twitter:text:title' content='website'>";
?>
我在这里缺少什么?是我检索数据的方式吗?请我尝试任何建议
【问题讨论】: