我需要添加到这个facebook og元数据?

时间:2014-09-24 07:21:40

标签: php facebook

我有一个分享按钮,我正在尝试根据我的特定需求进行修改。这是代码。

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:og="http://ogp.me/ns#"
xmlns:fb="http://www.facebook.com/2008/fbml">
<html>
<meta property="fb:app_id" content="lotsanumbers" />
<meta property="og:title" content="FOR SALE"/>
<meta property="og:type" content="product"/>
<meta property="og:url" content="http://www.website.com.au/php_test.php"/>
<meta property="og:image" content="http://www.website.com.au/ddfut14-1148.jpg"/>
<meta property="og:description" content="http://www.website.com.au/php_test.php<?php echo $title; ?>" />

除了og:description之外,一切都按要求运行。当我在facebook上调试facebook时才看到

<meta property="og:description" content="http://www.website.com.au/php_test.php

它不是在刮擦

<?php echo $title; ?> 

从同一行我错过了什么?

1 个答案:

答案 0 :(得分:0)

og:description是一个应包含文字的标记,你应该这样做:

<meta property="og:description" content="<?php echo $title; ?>" />
//where $title should be a defined variable that contains some text

<meta property="og:description" content="<?php echo file_get_contents("http://www.website.com.au/php_test.php"); ?>" />
//where your php_test.php file should echo out text