0

我的应用程序正在使用数据库记录的信息动态呈现 Facebook meta(og:title, og:title)。

当我从浏览器单击查看源代码时,我看到记录已正确呈现。但是,当我使用 Facebook 调试器 (https://developers.facebook.com/tools/debug) 查看完全相同的页面时,元标记的值为空,这意味着它不会从我的数据库中读取。

以前有人遇到过类似的问题,似乎应用程序速度不够快,无法呈现数据库记录?

代码 这是布局文件中的内容:

<?php 
// for Facebook
if(!isset($meta_title)) {
    $meta_title = 'Default title';
}
if(!isset($meta_location)) {
    $meta_location = FULL_BASE_URL.$this->here;
}
if(!isset($meta_image)) {
    $meta_image = FULL_BASE_URL.$this->webroot.'img/facebook-icon.gif';
}
if(!isset($meta_type)) {
    $meta_type = 'article';
}
if(!isset($meta_des)){
    $meta_des = 'Default title';
}   
?>

<meta property="og:site_name" content="<?php echo __('SgVoucher'); ?>"/>
<meta property="og:type" content="<?php echo $meta_type; ?>"/>
<meta property="og:title" content="<?php echo $meta_title; ?>"/>   
<meta property="og:url" content="<?php echo $meta_location; ?>"/>
<meta property="og:image" content="<?php echo $meta_image; ?>"/>
<meta property="og:description" content="<?php echo $meta_des; ?>"/>

在控制器中,我重试了数据库记录以给出动态标题。

//in the controller
$dynamic = $this->Model->find('first'....);
$this->set('meta_title',$dynamic['Table']['field']

但它永远不会从数据库中显示正确的,它总是从 Facebook 调试器显示“默认标题”,但是当您单击查看源时它是正确的。

链接如果它有助于调试, 该链接位于http://www.sgvoucher.com/deals/view/free_ipad_with_wi-fi_16gb_3rd_generation_giveaway 。

4

0 回答 0