2014-08-29 63 views
0

当我加载所有文章的信息时,信息被加载,但当我尝试分享时,它会得到错误的标题,desc和img。Facebook共享尝试加载不同文章的不同描述

$allPost = Post::getAllPageList(); 
     if (count($allPost)) { 
      $meta=''; 
      foreach ($allPost as $k => $v) { 
       $post = new Post($v); 
       $fileName = $post->getFirstPic($v); 
       $meta .= "<meta property='og:title' content='".$post->getTitle()."' />"; 
       $meta .= "<meta property='og:description' content='".strip_tags(html_entity_decode($post->getText(),ENT_QUOTES,'UTF-8'))."' />"; 
       $meta .= "<meta property='og:image' content='http://lateevents.com/upload/Post/GalleryBig/$fileName' />"; 
      } 
      echo $meta; 
     } 

当我试图通过文章过滤信息我失败,Facebook得到nothig。

CODE:

 $allPost = Post::getAllPageList(); 
     if (count($allPost)) { 
      $meta=''; 
      foreach ($allPost as $k => $v) { 
       if(isset($_GET['id']) && $_GET['id']!=$v) 
        continue; 
       $post = new Post($v); 
       $fileName = $post->getFirstPic($v); 
       $meta .= "<meta property='og:title' content='".$post->getTitle()."' />"; 
       $meta .= "<meta property='og:description' content='".strip_tags(html_entity_decode($post->getText(),ENT_QUOTES,'UTF-8'))."' />"; 
       $meta .= "<meta property='og:image' content='http://lateevents.com/upload/Post/GalleryBig/$fileName' />"; 
      } 
      echo $meta; 
     } 

的信息actualy正确加载但Facebook忽略它。

任何想法?

PS:我看到Facebook从here得到什么。

+0

你确定你是在输出meta标签,属于他们的地方? – 2014-08-29 10:28:36

+0

是的,他们在。 – belov91 2014-08-29 11:27:03

回答

0

的问题是在

如果(isset($ _ GET [ '身份证'])& & $ _GET [ '身份证']!= $ V)

。由于某种原因$_GET['id']应该被分配给变量。

CODE

$allPost = Post::getAllPageList(); 
     if (count($allPost)) { 
      $id=$_GET['id']; 
      $meta=''; 
      foreach ($allPost as $k => $v) { 
       if(isset($id) && $id!=$v) 
        continue; 
       $post = new Post($v); 
       $fileName = $post->getFirstPic($v); 
       $meta .= "<meta property='og:title' content='".$post->getTitle()."' />"; 
       $meta .= "<meta property='og:description' content='".strip_tags(html_entity_decode($post->getText(),ENT_QUOTES,'UTF-8'))."' />"; 
       $meta .= "<meta property='og:image' content='http://lateevents.com/upload/Post/GalleryBig/$fileName' />"; 
      } 
      echo $meta; 
     }