gpt4 book ai didi

javascript - Facebook Open Graph Sharing Debugger 无法很好地读取我的代码

转载 作者:行者123 更新时间:2023-11-29 17:53:25 26 4
gpt4 key购买 nike

当我在 open graph debugger 上检查我的 url 并再次点击 scrape

https://developers.facebook.com/tools/debug/sharing/?q=https%3A%2F%2Fwww.tvsrbija.online%2Findex.php

我得到一个奇怪的错误

our page has meta tags in the body instead of the head. This may be because your HTML was malformed and they fell lower in the parse tree. Please fix this in order for the tags to be usable.

但是当您查看源代码时,我的代码的一切都很好。我尝试抓取空白的 index.php 文件,当我这样做时,这是 Facebook 看到的内容

<!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></html>

但是没有这样的代码,如果我转到我网站的空白 index.php 页面并检查源代码,它是空白的...

但是,当我使用 index.html 而不是 index.php 时,Facebook 看不到任何代码,因为它应该有一个空的 index.php

问题是我的脚本是 php 而不是 html,所以我不能使用 html 扩展来解决问题。我什至尝试将 .php 扩展名重写为 html,因为我认为 Facebook 可能会以不同的方式处理它,但没有运气。我也尝试暂停 Cloudflare 几天,同样的事情......

它可以是什么?

编辑:在这里您可以看到 Facebook 如何看待我的源代码 https://developers.facebook.com/tools/debug/echo/?q=https%3A%2F%2Fwww.tvsrbija.online%2Findex.php

最佳答案

在提供的源链接中,您的输出没有页眉。它必须有一个有效的 head 和 body 节点才能成为有效的 html 标记。你可以在 facebook 提供的响应正文的前三行中看到这一点:

<!DOCTYPE html>
<html><body>
<p>&#65279;

Facebook 可能会转换您的 <head>标记为 <body>标记,因为您的来源不包含 <body> .你的 index.php 页面应该像这样抓取是正确的:

<!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></body></html>

将来,使用 w3c 验证器验证您的 html 标记以确保它是正确的:

https://validator.w3.org/

关于javascript - Facebook Open Graph Sharing Debugger 无法很好地读取我的代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41291912/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com