如果根据ID动态加载页面,我如何共享我创建的个人资料页面?
这是带有生成id的头标记 -
$id = $_GET['id'];
<meta property="og:url" content="https://www.my_site.com/page.php?id=<?php echo $id;?>" />
<meta property="og:title" content="Profile Name" />
<meta property="og:description" content="Your description" />
<meta property="og:image" content="https://www.my_site.com/path/image.jpg" />
继承人FB SDK -
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.11';
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
最后按钮本身 -
<div class="fb-share-button" data-href="https://www.my_site.com/page.php?id=<?php echo $id;?>>" data-layout="button_count" data-size="small" data-mobile-iframe="true"><a class="fb-xfbml-parse-ignore" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fwww.my_site.com%2Fpage.php%3Fid%3D%253C%253Fphp%2Becho%2B%2524id%253B%253F%253E&src=sdkpreparse">Share</a></div>
当我运行它时,它只显示主网站页面my_site.com而不是个人资料页面。