我使用会话值来设置facebook meta标签的内容:
<meta property="og:title" content="<?php print $_GET['p']; ?>"/>当我查看网站的源代码时,html如下所示:
<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.问题出在哪里?
发布于 2012-08-01 10:11:44
设置默认值
if(!isset($_GET['p'])){
$value = 'default value';
}else{
$value = $_GET['p'];
}
<meta property="og:title" content="<?php echo $value; ?>"/>默认值将出现在您的主页OG上
发布于 2012-08-01 10:05:27
当然,他不会被填充到http://www.palestinianz.com/中,因为在og:title中填充了URL中的p参数( get 'p')。如果我访问http://www.palestinianz.com/?p=Tivie,og:标题就会充满"Tivie“。
如果这是所需的效果,则将调试器指向一个person页面。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
https://stackoverflow.com/questions/11751386
复制相似问题