PHP:为 Facebook 元数据编码
最奇怪的事情:
我试图让 facebook 识别“&”在 字段中签名。
我从数据库中提取内容,在其中进行 urlencode: &变成 &
但 facebook 不会选择编码。除了,当我只是简单地将 &
添加到代码本身时,它会选择它看起来好像它在读取符号的 php 转换时遇到了问题。
有什么想法吗?被这个问题困住太久了。我一直在使用 facebook linter 来测试这一点。
Strangest thing:
I'm trying to get facebook to recognize the "&" sign within the <meta property='og:title' content="data"/>
field.
I have content being extracted from a db where I urlencode: & becomes &
but facebook doesn't pick up the encoding.. Except, when I just plainly add a &
to the code itself, it picks it up.. It seems as though it's specifically having an issue with reading the php conversion of the symbols.
Any idea? Been stuck on this for too long. I've been using the facebook linter to test this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议使用这样的方法:
printf('
', strip_tags(htmlentities("data")));I recommend using an approach like this:
printf('<meta property="og:description" content="%s" />', strip_tags(htmlentities("data")));
如果没有其他人为您提供准确的解决方案,我认为您可能会从查看原始 HTTP 流量中受益。工具有很多,最低级的是wire shark。
If nobody else gives you an exact fix, I think you might benefit from looking at the raw HTTP traffic. There are lots of tools, the lowest level is wire shark.