dongzhaoshi8497 2019-03-30 08:57
浏览 44

如何在同一页面中有2个不同的元数据到2个图像?

I have a page where I show several different images through a link with GET to show only one image at a time from a database. I wanted the page to read different metadata for each image that was displayed. Example:

If I open the page index.php or if I open index.php?p=[somenumber]

<?php
///////////////////////////////////////////////
if(isset($_GET['p'])){
    include 'inc_host.php';
    $p1=$_GET['p'];
    $sql = "SELECT * FROM upload WHERE p = $p1";
    $result = $conn->query($sql);

    if ($result->num_rows > 0) {
        // output data of each row
        while($row = $result->fetch_assoc()) {
            $meta_t = $row["title"];
            $meta_c = $row["content"];
        }
    }

    $meta_img = "img.jpg";
    ?>
  <meta property="og:title" content="<?php echo $meta_t; ?>" />
<meta property="og:description" content="<?php echo $meta_c; ?>" />
<meta property="og:url" content="https://www.example.com/index.php?p=<?php echo $p1; ?>" />
<meta property="og:image" content="https://www.example.com/<?php echo $meta_img; ?>" />
<?php }

else
{
?> 
<meta property="og:title" content="My title" />
<meta property="og:description" content="My content." />
<meta property="og:url" content="https://www.example.com" />
<meta property="og:image" content="https://www.example.com/img_index.jpg" />
<?php
}
//////////////////////////////////////////////////
?>

The code works in HTML but if I use the link www.example.com/index.php?p=[somenumber] to post on facebook, I get this error: facebook error

Facebook dont read my metadata!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料