我的网页是odalternatives.com/5-questions-that-can-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中粘贴链接或其他任何地方它显示我
时