Facebook无法掌握我的og:图像文件,我已经尝试了所有常见的解决方案。我开始认为这可能与https://..有关。

I have checked http://developers.facebook.com/tools/debug and have zero warnings or errors. It is finding the images we linked to in the "og:image", but they're showing up blank. When we click the image(s), however, they DO exist and it takes is straight to them. It DOES show one image -- an image hosted on a non-https server. We've tried square images, jpegs, pngs, larger sizes and smaller sizes. We've put the images right in public_html. Zero are showing up. It's not a caching error, because when we add another og:image to the meta, FB's linter does find and read that. It DOES show a preview. The preview is blank. The only exception we're getting is for images that are not on this website. We thought maybe there was some anti-leach on cpanel or the .htaccess that was preventing the images from showing up, so we checked. There was not. We even did a quick < img src="[remote file]" > on an entirely different server and the image shows up fine. We thought maybe it was the og:type or another oddity with another meta tag. We removed all of them, one at a time and checked it. No change. Just warnings. The same code on a different website shows up without any issue. We thought maybe it was not pulling images because we're using the same product page(s) for multiple products (changing it based on the get value, ie, "details.php?id=xxx") but it's still pulling in one image (from a different url). Leaving any og:image or image_src off, FB does not find any images.

我已经山穷水尽了。如果我说我自己和其他人在这方面花了多少时间,你会感到震惊。问题是这是一个在线商店。我们绝对绝对不能没有图像。我们必须这么做。我们还有十多个其他网站……这是唯一一个有og:图像问题的。它也是唯一一个使用https的,所以我们认为这可能是问题所在。但我们在网上找不到任何这样的先例。

这些是元标签:

<meta property="og:title" content="[The product name]" /> 
<meta property="og:description" content="[the product description]" /> 
<meta property="og:image" content="https://www.[ourwebsite].com/images/shirts/overdriven-blues-music-tshirt-details-black.png" />
<meta property="og:image" content="https://www.[ourwebsite].com/images/shirts/overdriven-blues-music-tshirt-art-black.png" />
<meta property="og:image" content="http://www.[ADIFFERENTwebsite].com/wp-content/uploads/2011/06/ARS-Header-Shine2.png" />
<meta property="og:image" content="https://www.[ourwebsite].com/images/ARShopHeader.png" />
<meta property="og:image" content="http://www.[ourwebsite].com/overdriven-blues-music-tshirt-art-black.JPG" />
<meta property="og:type" content="product"/>
<meta property="og:url" content="https://www.[ourwebsite].com/apparel-details.php?i=10047" />
<meta property="og:site_name" content="[our site name]" />      
<meta property="fb:admins" content="[FB-USER-ID-NUMBER]"/>
<meta name="title" content="[The product name]" />
<meta name="description" content="[The product description]" />
<link rel="image_src" href="https://www.[ourwebsite].com/images/shirts/overdriven-blues-music-tshirt-details-black.png" />
<meta name="keywords" content="[four typical keywords]">
<meta name="robots" content="noarchive">

如果你想要它,这里有一个链接到我们一直在做的产品页面。[缩短链接,试图阻止这进入我们网站的搜索结果]:http://rockn.ro/114

编辑——

使用“see what facebook sees”刮刀工具,我们可以看到以下内容:

"image": [          
      {
         "url": "https://www.[httpSwebsite].com/images/shirts/soul-man-soul-music-tshirt-details-safari.png"
      },
      {
         "url": "https://www.[httpSwebsite].com/images/shirts/soul-man-soul-music-tshirt-art-safari.png"
      },
      {
         "url": "http://www.[theotherNONSECUREwebsite].com/wp-content/uploads/2011/06/ARS-Header-Shine2.png"
      }
   ],

我们测试了它为单个页面找到的所有链接。所有这些都是完全有效的图像。

编辑2 ----

我们尝试了一个测试,并在NONSECURE网站上添加了一个子域名(从该网站上的图像实际上可以通过facebook看到)。子域名为http://img.[nonsecuresite].com。然后,我们将所有图像放入主子域文件夹并引用它们。它不会把这些图片拉进FB。但是,它仍然会提取在不安全的主域上引用的任何图像。

发布的解决方案----

Thanks to Keegan, we now know that this is a bug in Facebook. To workaround, we placed a subdomain in a different NON-HTTPS website and dumped all images in it. We referenced the coordinating http://img.otherdomain.com/[like-image.jpg] image in og:image on each product page. We then had to go through FB Linter and run EVERY link to refresh the OG data. This worked, but the solution is a band-aid workaround, and if the https issue is fixed and we go back to using the natural https domain, FB will have cached the images from a different website, complicating matters. Hopefully this information helps to save someone else from losing 32 coding hours of their life.


当前回答

我努力寻找答案,却从领英(LinkedIn)上得到了一个令人费解的错误:

我们在尝试访问URL时遇到了SSL连接错误。 请检查该网站使用的主要大小是否兼容 使用Java 8,或通过内容的URL联系技术支持。

答案是,尽管我在nginx中启用了TLSv1.2和TLSv1.3,但由于这个检查器验证了我的密码列表,TLSv1.2不可用。facebook和linkedin似乎都使用TLSv1.2来生成预览(截至2022年11月)。

根据这篇文章的第一个答案,我不得不将nginx更新为以下内容:

ssl_protocols TLSv1.3 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+AESGCM,EDH+AESGCM";

其他回答

我不知道,如果它只是与我,但我og:image不工作,它选择我的网站标志,即使facebook调试器显示正确的图像。

但是将og:image更改为og:image:url对我来说是可行的。希望这能帮助其他面临类似问题的人。

我偶然发现,透明的空白图像带有响应头,指示问题的可能原因。

转到调试器https://developers.facebook.com/tools/debug/og/object/ 写上你的URL 在底部,facebook显示你的“图像”(透明1x1 GIF) 图像链接到您的原始图像-没有点按它 按右键查看图片(你会看到类似https://external-ams3-1.xx.fbcdn.net/safe_image.php?d=...&url=…) 打开firebug/开发者工具的Net选项卡,如果需要,刷新页面 您将得到带有解释的x-error-detail响应头

例如,在我的例子中,它是URL的无效图像扩展名:https://[mydomain]/[myfilename].jpg

在我的案例中,真正的问题与prerender.io有关。

事实证明,如果图像是通过预渲染请求的,它会被转换为HTML。就像这样:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head>
<body style="margin: 0px;"><img style="-webkit-user-select: none; cursor: -webkit-zoom-in; " src="https://[yourdomain].com/[yourfilename].jpg" width="1078" height="718"></body>
</html>

这要么是预渲染本身的错误,要么是在代理中配置不使用预渲染*.jpg请求(即使它们是由Facebook机器人请求的)。

很难注意到这一点,因为预渲染只在某些用户代理头上使用。

此外,当您添加用户生成的故事(不使用og:image)时,也会出现这个问题。例如:

POST /me/cookbook:eat?
  recipe=http://www.example.com/recipes/pizza/&
  image[0][url]=http://www.example.com/recipes/pizza/pizza.jpg&
  image[0][user_generated]=true&
  access_token=VALID_ACCESS_TOKEN

以上内容只适用于http,而不适用于https。如果你使用https,你会得到一个错误说: attach image()上传失败

如果你的图片链接是这样的: “https://someurl 2022年9月14日星期三05:59:25 GMT+0000(协调世界时).jpg”

然后确保在设置URL时使用encodeURI函数(JavaScript)或其他语言中的任何类似函数。

这将帮助您创建一个可以被og:image理解的有效URL。

{ 
  'og:title': "title",
  'og:description': "description",
  'og:image': encodeURI(image),
  'og:image:secure_url': encodeURI(image),
}

有些属性可以附加额外的元数据。这些元数据的指定方式与其他具有属性和内容的元数据相同,但属性将有额外的:

image属性有一些可选的结构化属性:

og:image:url -与og:image相同。 image:secure_url—An 如果网页需要HTTPS,可以使用其他url。 og:image:type - A 此映像的MIME类型。 og:image:width -像素的宽度。 og:image:height -高的像素数。

完整的图像示例:

<meta property="og:image" content="http://example.com/ogp.jpg" />
<meta property="og:image:secure_url" content="https://secure.example.com/ogp.jpg" /> 
<meta property="og:image:type" content="image/jpeg" /> 
<meta property="og:image:width" content="400" /> 
<meta property="og:image:height" content="300" />

因此,您需要将HTTPS url的og:image属性更改为og:image:secure_url

Ex:

图片的HTTPS元标签:

<meta property="og:image:secure_url" content="https://www.[YOUR SITE].com/images/shirts/overdriven-blues-music-tshirt-details-black.png" />

图片的HTTP元标签:

<meta property="og:image" content="http://www.[YOUR SITE].com/images/shirts/overdriven-blues-music-tshirt-details-black.png" />

来源:http://ogp.me/#structured <—您可以访问该网站了解更多信息。

编辑:不要忘记在更新代码后ping facebook服务器- URL Linter