角度网页未在FB中显示元标记

时间:2016-07-06 08:47:50

标签: angularjs facebook debugging seo

我的网页是odalternatives.com/5-questions-that-c​​an-transform-leaders-and-their-organizations

参考本页 - https://rck.ms/angular-handlebars-open-graph-facebook-share/

我尝试修复但失败了

.httpaccess是

Options +FollowSymLinks -MultiViews

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_USER_AGENT} (facebookexternalhit/[0-9]|Twitterbot|Pinterest|Google.*snippet)
RewriteRule ^([^/]*)$ http://www.odalternatives.com/static.php?id=$1 [P]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*)$ /index.php?action=$1 [L]
需要由FB TWITTER渲染的

static.php是

<?php
// 1. get the content Id (here: an Integer) and sanitize it properly
$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_STRING);

// 2. get the content from a flat file (or API, or Database, or ...)
$data = json_decode(file_get_contents('./meta/'.$id.'.json'));

// 3. return the page
return makePage($data); 

function makePage($data) {
    // 1. get the page
    $pageUrl = $data->id;
    // 2. generate the HTML with open graph tags
    $html  = '<!doctype html>'.PHP_EOL;
    $html .= '<meta name="author" content="'.$data->name.'"/>'.PHP_EOL;
    $html .= '<meta property="og:title" content="'.$data->title.'"/>'.PHP_EOL;
    $html .= '<meta property="og:description" content="'.$data->description.'"/>'.PHP_EOL;
    $html .= '<meta property="og:image" content="'.$data->poster.'"/>'.PHP_EOL;
    // 3. return the page
    echo $html;
}

当我在FB中粘贴链接或其他任何地方它显示我

https://developers.facebook.com/tools/debug/echo/?q=http%3A%2F%2Fodalternatives.com%2F5-questions-that-can-transform-leaders-and-their-organizations

0 个答案:

没有答案