Facebook OG 对象调试器是否以某种方式跳过 PHP?
我有一个动态 PHP 页面,主要显示视频。当 Facebook 用户点击视频时,时间线事件会发布到他们的 Facebook 个人资料中,但我的 OG 元标记似乎不想与存储视频信息的 PHP 变量配合。
如果我直接输入正确的字符串进入元标签,一切都很好,但是页面设计从我的数据库中选择了一个视频。
这些是包含 PHP 变量的当前标签:
<head prefix='og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# visiovert: http://ogp.me/ns/fb/visiovert#'>
<meta property='fb:app_id' content='261459743887413'>
<meta property='og:type' content='visiovert:advertisement'>
<meta property='og:url' content='http://visiovert.net/ad.php'>
<meta property='og:site_name' content='VisioVert'>
<?php
echo("<meta property=\"og:title\" content=\"".$Video->title."\" />\n");
echo("<meta property=\"og:description\" content=\"".$Video->description."\" />\n");
echo("<meta property=\"og:image\" content=\"".$Video->location.".jpg\" />\n");
echo("<meta property=\"og:video\" content=\"".$Video->location.".mp4\" />\n");
?>
<meta property='og:video:height' content='432' >
<meta property='og:video:width' content='768'>
</head>
如果您查看页面源代码,这就是您可以在标题中看到的内容:
<head prefix='og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# visiovert: http://ogp.me/ns/fb/visiovert#'>
<meta property='fb:app_id' content='261459743887413'>
<meta property='og:type' content='visiovert:advertisement'>
<meta property='og:url' content='http://visiovert.net/ad.php'>
<meta property='og:site_name' content='VisioVert'>
<meta property="og:title" content="Echo" />
<meta property="og:description" content="An example video ad for VisioVert." />
<meta property="og:image" content="http://visiovert.net/Videos/echo.jpg" />
<meta property="og:video" content="http://visiovert.net/Videos/echo.mp4" />
<meta property='og:video:height' content='432' >
<meta property='og:video:width' content='768'>
</head>
这与我想要的完全匹配,但是在使用 Facebook 对象调试器进行测试时,它没有得到PHP 变量之外的任何内容。我可能会错过一些就在我面前的东西……但我环顾四周并没有找到答案。
I have a dynamic PHP page that basically displays a video. When a Facebook user clicks on the video, a timeline event is posted to their Facebook profile, but my OG meta tags don't seem to want to cooperate with the PHP variables the video information is stored in.
If I type the correct strings directly into the meta tags, everything works great, but the page by design picks a video from my Database.
These are the current tags with PHP Variables included:
<head prefix='og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# visiovert: http://ogp.me/ns/fb/visiovert#'>
<meta property='fb:app_id' content='261459743887413'>
<meta property='og:type' content='visiovert:advertisement'>
<meta property='og:url' content='http://visiovert.net/ad.php'>
<meta property='og:site_name' content='VisioVert'>
<?php
echo("<meta property=\"og:title\" content=\"".$Video->title."\" />\n");
echo("<meta property=\"og:description\" content=\"".$Video->description."\" />\n");
echo("<meta property=\"og:image\" content=\"".$Video->location.".jpg\" />\n");
echo("<meta property=\"og:video\" content=\"".$Video->location.".mp4\" />\n");
?>
<meta property='og:video:height' content='432' >
<meta property='og:video:width' content='768'>
</head>
If you view the page source, this is what you can see in the header:
<head prefix='og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# visiovert: http://ogp.me/ns/fb/visiovert#'>
<meta property='fb:app_id' content='261459743887413'>
<meta property='og:type' content='visiovert:advertisement'>
<meta property='og:url' content='http://visiovert.net/ad.php'>
<meta property='og:site_name' content='VisioVert'>
<meta property="og:title" content="Echo" />
<meta property="og:description" content="An example video ad for VisioVert." />
<meta property="og:image" content="http://visiovert.net/Videos/echo.jpg" />
<meta property="og:video" content="http://visiovert.net/Videos/echo.mp4" />
<meta property='og:video:height' content='432' >
<meta property='og:video:width' content='768'>
</head>
That matches exactly what I would like it to, but when testing using the Facebook Object Debugger, it is not getting anything out of PHP variables. I could be missing something right in front of me...but I've looked around and haven't found an answer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Veliisx
尝试将 fb 命名空间添加到您的 html 标记中。
ps 在你的源中只有一半的标签是关闭的。不确定这是否会被忽略,但会在某些浏览器中导致错误。
Veliisx
try adding fb namespace to your html tag.
p.s. in your source only half of the tags are closed. Not sure if this would be ignored but will cause errors in some browsers.
我也经常遇到转义问题,您是否尝试过类似下面的方法来避免大量转义?
下面基本上是如何动态添加我的元,我知道它需要更多的代码来回显每个元,但它避免了与转义的很多混淆。
I often have issues with escaping too, have you tried something like below to avoid the heavy escaping?
The below is basicly how dynamically add my meta, i know its a bit more code to echo each but it avoids a lot of confusion with escaping.