从数据库到推特卡(PHP)中链接的图像

问题描述 投票:0回答:1

我正在尝试将数据库中的图像插入Twitter卡(链接),但该链接显示在推文中,但没有图像

tweet卡示例(链接)

enter image description here

试图为tweet卡制作默认图像,并且效果很好

但是当我尝试从数据库中检索图像的名称并将其放在<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'>";

?>

我在这里想念什么?是我检索数据的方式吗?请我尝试任何建议

php html mysql twitter
1个回答
0
投票

我不知道您如何将图像保存到位置或数据库中,但是根据您的问题,阅读此书,看看是否错过了什么

© www.soinside.com 2019 - 2024. All rights reserved.