我希望能够与facebook按钮共享动态页面。
该按钮适用于静态页面,但不适用于动态页面。我的动态页面是在$ profie_url中创建的。如何在Facebook代码中使用它?
$mRow = $this->row;
$wRow = $mRow->getInfo();
<?php $profie_url = $this->url(array("id" => $mRow->id, "url" =>
$this->urlify($mRow->first_name)));
?>
<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 = "//connect.facebook.net/fr_CA/sdk.js#xfbml=1&version=v2.8";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-share-button" data-href="<?php echo $profie_url; ?>" data-layout="button" data-mobile-iframe="true"><a class="fb-xfbml-parse-ignore" target="_blank" href="">Share</a></div>
答案 0 :(得分:1)
溶液:
$id= $mRow->id;
$fn = $mRow->first_name;
<script language="javascript">
var id= <?php echo json_encode($id); ?>;
var fn = <?php echo json_encode($fn); ?>;
function fbshareCurrentPage()
{window.open("https://www.facebook.com/sharer/sharer.php?u=www.abc.com/"+id+"/"+fn+"&t="+document.title, '',
'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600');
return false; }
</script>