类似Facebook的php代码集og:image


Facebook like - php code - set og:image

我的网站上有facebook按钮。它看起来像:

<span class="fblike" style="float:right;padding-top:5px;margin-left:8px;">
    <div id="fb-root"></div>
        <script>
            window.fbAsyncInit = function() 
            {
                FB.init({appId: 'Your ID#', status: true, cookie: true,xfbml: true});
            };
            (function() {
                var e = document.createElement('script'); e.async = true;
                e.src = document.location.protocol + '//connect.facebook.net/sk_SK/all.js';
                document.getElementById('fb-root').appendChild(e);
            }());
        </script>
        <fb:like layout="button_count" show_faces="false" width="64" action="like" font="arial" colorscheme="light" />
</span>

我的问题是,我无法设置我想要的og:image:(无论我在哪里放置标记。它应该在标记中,但在我的default.php文件中没有。我在joomla中工作,它是我的组件之一。

要在所有初始化后在FB墙上显示您选择的图像,您应该:

  1. 用替换HTML标签

    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml">
    
  2. 在头部添加og标签:

    <meta property="og:title" content="title of your page"/>
    <meta property="og:type" content="website"/>
    <meta property="og:url" content="url of your page"/>
    <meta property="og:image" content="path of image u want to display"/>
    <meta property="og:site_name" content="name of your site"/>
    <meta property="og:description" content="some brief description about your page "/>
    <meta property="fb:app_id" content="your fb app id"/>
    

在此之后,您可以使用此调试器工具检查从您的站点废弃的数据。

如果没有错误或警告,您都可以使用类似按钮。

Open Graph元标记应该在head部分中,并且HTML应该是正确的。首先,要确定这一点。

使用这个工具来检查facebook如何解析你的网站。