2017-01-09 138 views
-1

我希望能夠與facebook按鈕共享動態頁面。
該按鈕適用於靜態頁面,但不適用於動態頁面。我的動態頁面是在$ profie_url中創建的。我如何在Facebook代碼中使用它?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

能否請您解釋一下?你想要做什麼? – Nerazzurri

+0

分享按鈕的代碼是用於靜態頁面的。我希望能夠分享一個動態頁面。動態網址是在$ profie_url – NewPassionnate

+0

中定義的,您的網址是否仍在同一頁面上更改? – Nerazzurri

回答

0

解決方案:

$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>