Facebook Open Graph API - og:元标签被忽略

发布于 2024-12-13 16:32:33 字数 1811 浏览 0 评论 0 原文

我正在解决页面标题和图像未包含在 Facebook 点赞中的问题。点击 OG 调试器后,facebook 似乎没有访问任何 og: 元标签:

这是调试器的链接 - 它表示它正在推断 og:url 和 og:title 属性,这些属性存在于页。

作为测试,我直接从开发人员文档的示例中复制了元标记和 HTML 架构,但仍然收到相同的警告。

这是生成的 HTML 和 head 标签的开头:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<title>123-ABC Butterfly Fun Carpet 3'10" x 5'5" Rectangle</title>
<meta name="description" content="Transactiv Products" />
<meta name="title" content="Transactiv" />
<meta property="fb:app_id" content="289501899130" />
<meta property="og:site_name" content="Transactiv InRecv" />
<meta property="og:url" content="http://localhost:2609/Pages/ProductSummary.aspx?OrganizationProductID=617c54a0-189a-48af-9b5e-002148210208&StoreID=a1d6bc99-9a6a-4e46-bdb4-790be4e59bd4&ProductID=d6748a89-41f4-48aa-a1c1-5c28f87cc47f&PageName=MHMTest&PageID=236549899706529" />
<meta property="og:title" content="123-ABC Butterfly Fun Carpet 3'10" x 5'5" Rectangle" />
<meta property="og:type" content="website" />
<meta property="og:description" content="" />
<meta property="og:image" content="http://transactivazureprod.blob.core.windows.net/pictureblob/831a4d4a-dbe3-44f5-9ff8-12286cdc33f5" />

对此有什么想法吗?

I'm troubleshooting an issue where the page title and image aren't being included on facebook likes. Having hit the OG debugger, it looks like none of the og:metatags are being accessed by facebook:

Here's a link to the debugger — it's saying it is inferring the og:url and og:title properties which are present on the page.

As a matter of testing, I copied the metatags and HTML schema straight from the example on the developer docs and I still get the same warnings.

Here's the HTML and start of the head tag as generated:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<title>123-ABC Butterfly Fun Carpet 3'10" x 5'5" Rectangle</title>
<meta name="description" content="Transactiv Products" />
<meta name="title" content="Transactiv" />
<meta property="fb:app_id" content="289501899130" />
<meta property="og:site_name" content="Transactiv InRecv" />
<meta property="og:url" content="http://localhost:2609/Pages/ProductSummary.aspx?OrganizationProductID=617c54a0-189a-48af-9b5e-002148210208&StoreID=a1d6bc99-9a6a-4e46-bdb4-790be4e59bd4&ProductID=d6748a89-41f4-48aa-a1c1-5c28f87cc47f&PageName=MHMTest&PageID=236549899706529" />
<meta property="og:title" content="123-ABC Butterfly Fun Carpet 3'10" x 5'5" Rectangle" />
<meta property="og:type" content="website" />
<meta property="og:description" content="" />
<meta property="og:image" content="http://transactivazureprod.blob.core.windows.net/pictureblob/831a4d4a-dbe3-44f5-9ff8-12286cdc33f5" />

Any ideas on this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

爱本泡沫多脆弱 2024-12-20 16:32:33

Facebook 会读取您可以在此处输入网址的所有属性:
https://developers.facebook.com/tools/debug

Facebook 将读取您指定的属性,但有时仅当指定所有 4 个(且不为空)时才会使用它们,而不仅仅是最后 3 个

<meta property="og:url" content="YOUR_URL" />
<meta property="og:title" content="YOUR_TITLE" />
<meta property="og:description" content="YOUR_DESCRIPTION" />
<meta property="og:image" content="YOUR_IMAGE" />

Facebook reads all properties you can enter your url here:
https://developers.facebook.com/tools/debug

Facebook will read the properties you specified, but sometimes will use them only when all 4 are specfied (and not empty), not only the last 3.

<meta property="og:url" content="YOUR_URL" />
<meta property="og:title" content="YOUR_TITLE" />
<meta property="og:description" content="YOUR_DESCRIPTION" />
<meta property="og:image" content="YOUR_IMAGE" />
幽蝶幻影 2024-12-20 16:32:33

明显的缺陷。你没有直接结束标题。你里面有 "

我建议在 echo'ing 之前执行 str_replace('"', "''", $str)

编辑:

您还可以考虑执行 htmlentities($str, ENT_QUOTES),如 @TwoWholeWorms 所建议,

Obvious flaw. You don't propely end the title. You got " in it.

I'd suggest doing a str_replace('"', "''", $str) before echo'ing it.

That is,

<meta property="og:title" content="123-ABC Butterfly Fun Carpet 3'10" x 5'5" Rectangle" />

to

<meta property="og:title" content="123-ABC Butterfly Fun Carpet 3'10'' x 5'5'' Rectangle" />

EDIT:

You can also consider doing htmlentities($str, ENT_QUOTES), as suggested by @TwoWholeWorms,

风月客 2024-12-20 16:32:33

Facebook 的抓取工具在尝试 访问您的网站

您可以通过调试页面底部的“准确查看我们的抓取工具所看到的内容”链接来访问 Facebook 抓取工具的页面视图。

此外,它似乎不仅仅是一个与抓取相关的问题,因为当我访问链接时我也看到了相同的消息:http://transactivstaging.cloudapp.net:8080/Pages/ProductSummary.aspx?OrganizationProductID=617c54a0-189a​​-48af-9b5e-002148210208&StoreID=a1d6bc99-9a6a-4 e46-bdb4-790be4e59bd4&ProductID=d6748a89-41f4-48aa-a1c1-5c28f87cc47f&FBUserId =100002152993326&PageName=MHMTest&PageID=236549899706529&CurrentPage=0

ShoppingCart.GetShoppingCartItems.Failed If this Error persists, you can contact our support and provide the following Error Id as a reference

Facebook's scraper is seeing an error page when it tries to visit your site.

You can access the Facebook scraper's view of your pages through the link 'See exactly what our scraper sees' at the bottom of the debug page.

Also it doesn't just seem to be a scraper related problem as I'm also seeing the same message when I visit the link: http://transactivstaging.cloudapp.net:8080/Pages/ProductSummary.aspx?OrganizationProductID=617c54a0-189a-48af-9b5e-002148210208&StoreID=a1d6bc99-9a6a-4e46-bdb4-790be4e59bd4&ProductID=d6748a89-41f4-48aa-a1c1-5c28f87cc47f&FBUserId=100002152993326&PageName=MHMTest&PageID=236549899706529&CurrentPage=0

ShoppingCart.GetShoppingCartItems.Failed If this Error persists, you can contact our support and provide the following Error Id as a reference
梦里寻她 2024-12-20 16:32:33

我猜想,以及 Robin Castlin" > (您也可以将其转义为 "),您的 og:url 包含未转义的 & 符号,

如果替换 & 是否有效 。代码> 与& 位于 og:url 字段中?

因此您需要替换

<meta property="og:title"
  content="123-ABC Butterfly Fun Carpet 3'10" x 5'5" Rectangle" />
<meta property="og:url"
  content="http://localhost:2609/Pages/ProductSummary.aspx?
  OrganizationProductID= ... &StoreID= ..." />

to

<meta property="og:title"
   content="123-ABC Butterfly Fun Carpet 3'10" x 5'5" Rectangle" />

<meta property="og:url"
  content="http://localhost:2609/Pages/ProductSummary.aspx?
  OrganizationProductID= ... &StoreID= ..." />

以确保元数据全部包含有效的 HTML。

I would guess that, as well as the " in the title values mentioned by Robin Castlin (which you could also escape as "), that your og:url contains unescaped ampersands.

Does it work if you replace & with & in that og:url field?

So you'd replace

<meta property="og:title"
  content="123-ABC Butterfly Fun Carpet 3'10" x 5'5" Rectangle" />
<meta property="og:url"
  content="http://localhost:2609/Pages/ProductSummary.aspx?
  OrganizationProductID= ... &StoreID= ..." />

to

<meta property="og:title"
   content="123-ABC Butterfly Fun Carpet 3'10" x 5'5" Rectangle" />

<meta property="og:url"
  content="http://localhost:2609/Pages/ProductSummary.aspx?
  OrganizationProductID= ... &StoreID= ..." />

to make sure the metadata all contains valid HTML.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文