我无法让 Facebook 抓取我发布到博客的链接

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

当我在 Facebook 上发布我所做的博客文章的链接时,没有显示正确的图片。我尝试将 og 标签添加到我的博客代码中的各种内容中,但没有任何效果。帮助!

我尝试了 linter,这就是我得到的。推断属性:即使可以从其他标签推断出值,也应显式提供“og:description”属性。 推断属性:即使可以从其他标签推断出值,也应显式提供“og:image”属性。

我必须开始在每一篇帖子中添加 og 标签吗?

http://michelleglauser.blogspot.com

image facebook web-scraping hyperlink blogger
2个回答
0
投票

当您在 Facebook 上发布/分享链接时,该链接有一个 url,Facebook 需要为每个 url 提供 og 标签。

例如 http://michelleglauser.blogspot.comhttp://michelleglauser.blogspot.com/2012/04/links-to-love-week-14-2012.html 是两个不同的网址,每个网址如果你想控制 facebook 呈现它们的方式,就必须有 og 标签。

我查看了您网站的 html 代码,看起来您确实提供了 og:title、og:type 和 og:url,但 og:image 和 og:description 由于某种原因被注释掉了,它们在代码中是这样的吗:

<!--
/*
<meta property="og:image" content="http://s191.photobucket.com/albums/z72/MichemilyG/Blog/?action=view&current=Circles-and-Dots-and-Other-Distractions-Michelle-Glauser-Blog-Header-Flat.jpg"/>
<link rel="http://s191.photobucket.com/albums/z72/MichemilyG/Blog/?action=view&current=Circles-and-Dots-and-Other-Distractions-Michelle-Glauser-Blog-Header-Flat.jpg" href="thumbnail_image" / >
<meta property="fb:title" content="Circles and Dots and Other Distractions"/>
<meta property="og:description" content="Michelle Glauser"/>
...

您需要将这些标签与其余的 og 标签放在一起。


0
投票

这是我刚刚在我正在开发的 WordPress 网站上实现的示例(blogger 有点不同)。基本上,它会检查您当前所在的页面是否有关联的英雄图像。如果是的话,它会使用该英雄图像。如果没有,它将使用徽标图像。这样,当我“喜欢”我的一篇博客文章时(即使是从首页,而不是从博客文章页面本身),Facebook 会 ping 该 url 并查找关联的 og:image 和 og:description 标签。

<?php
    wp_reset_query();
    $fb_image = ui::getImage(290, 121, "align left");
    if(!$fb_image){
        $fb_image = ui::logo();
    }
?>

<meta property="og:site_name" content="<?php ui::title(); ?>"/>
<meta property="og:title" content="<?php the_title(); ?>"/>
<meta property="og:url" content="<?php the_permalink(); ?>"/>
<meta property="og:image" content="<?php echo $fb_image ?>"/>

顺便说一句,这位于每个页面的“头部”部分

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