当我加载所有文章的信息时,信息被加载但当我尝试分享它时会得到错误的标题,desc和img。
$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就没有了。
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;
}
信息是正确加载的,但facebook忽略了它。
有什么想法吗?
PS:我看到Facebook从here获得了什么。
答案 0 :(得分:0)
问题在于
if(isset($ _ GET ['id'])&amp;&amp; $ _GET ['id']!= $ 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;
}