Facebook OG 对象调试器是否以某种方式跳过 PHP?

发布于 2024-12-07 05:39:45 字数 2156 浏览 0 评论 0原文

我有一个动态 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 技术交流群。

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

发布评论

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

评论(2

懒的傷心 2024-12-14 05:39:45

Veliisx

尝试将 fb 命名空间添加到您的 html 标记中。

 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://ogp.me/ns#" xmlns:shawnsspace="http://www.shawnsspace.com/ns#">

ps 在你的源中只有一半的标签是关闭的。不确定这是否会被忽略,但会在某些浏览器中导致错误。

Veliisx

try adding fb namespace to your html tag.

 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://ogp.me/ns#" xmlns:shawnsspace="http://www.shawnsspace.com/ns#">

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.

维持三分热 2024-12-14 05:39:45

我也经常遇到转义问题,您是否尝试过类似下面的方法来避免大量转义?
下面基本上是如何动态添加我的元,我知道它需要更多的代码来回显每个元,但它避免了与转义的很多混淆。


<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="<?php echo $Video->title; ?>" />
<meta property="og:description" content="<?php echo $Video->description; ?>" />
<meta property="og:image" content="<?php echo $Video->location; ?>.jpg" />
<meta property="og:video" content="<?php echo $Video->location; ?>.mp4" />

    <meta property='og:video:height' content='432' >
    <meta property='og:video:width' content='768'>
</head>

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.


<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="<?php echo $Video->title; ?>" />
<meta property="og:description" content="<?php echo $Video->description; ?>" />
<meta property="og:image" content="<?php echo $Video->location; ?>.jpg" />
<meta property="og:video" content="<?php echo $Video->location; ?>.mp4" />

    <meta property='og:video:height' content='432' >
    <meta property='og:video:width' content='768'>
</head>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文