2012-08-01 49 views
0

我使用session值来设置Facebook的meta标签的内容:当我查看网页的源HTML出现这样动态内容:标题Facebook的meta标签

<meta property="og:title" content="<?php print $_GET['p']; ?>"/> 

<meta property="og:title" content="Alex Atalla"/> 

这意味着它已成功填充标题元标记内容中的会话值的值。

但是,当我使用Facebook的调试器它说:

Object Missing a Required Value: Object at URL 'http://www.palestinianz.com/' of type 'website' is invalid because a required property 'og:title' of type 'string' was not provided. 

是什么问题?

+0

当我测试使用fac的URL电子书调试器:https://developers.facebook.com/tools/debug – 2012-08-01 01:29:56

+1

只需查看palestinianz.com的来源,标题标签就在那里,但主页上没有值 – 2012-08-01 01:31:40

+0

@DerekHunziker值什么? – 2012-08-01 01:33:33

回答

1

设置默认值

if(!isset($_GET['p'])){ 
$value = 'default value'; 
}else{ 
$value = $_GET['p']; 
} 

<meta property="og:title" content="<?php echo $value; ?>"/> 

默认价值将在您的主页上OG

+0

但为什么总是$ _GET ['p']是空的?! – 2012-08-01 02:21:34

0

嗯,当然他没有填写http://www.palestinianz.com/,因为og:标题正在用URL中的p参数填充(GET ['p'])。如果我访问http://www.palestinianz.com/?p=Tivie,og:title会填充“Tivie”。

如果这是所需的效果,请将调试器指向个人页面。 http://www.palestinianz.com/?p=Alex-Atalla什么的。

编辑: 我想我明白你想要做什么。 如果你不介意我的建议......

改变你的代码如下:

<meta property="og:title" content="<?php print (isset($_GET['p'])) ? $_GET['p'] : 'They Are Palestinians'; ?>"/> 

然后了解Apache Mod Rewrite

+0

是的,但https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fpalestinianz.com%2F%3Fpage%3Dperson%26p% 3DEdward-Said说,除非在URL – 2012-08-01 02:07:33

+0

中有p,否则为什么总是$ _GET ['p']是空的? – 2012-08-01 02:24:06

+0

$ _GET ['p']是p =网址中的内容。如果url中没有p = something,$ _GET ['p']是空的! – Tivie 2012-08-01 10:34:32