动态设置FB Sharer og:description

时间:2017-12-01 19:58:51

标签: javascript php fbsdk fbsdksharedialog

您好我想使用fb sharer进行多个项目的页面共享。但据我所知,我需要在元标记上加上描述标题。但是,如果我希望它是动态的呢?例如,我点击一个项目,根据项目,我点击fb sharer弹出窗口将出现并显示我点击的项目的详细信息。这甚至可能吗?现在下面是我的代码

<meta property="og:url"           content="{{ $data['url'] }}" />
<meta property="og:type"          content="{{ $data['type'] }}" />
<meta property="og:title"         content="{{ $data['title'] }}" />
<meta property="og:description"   content="{{ $data['description'] }}" />
<meta property="og:image"         content="{{ $data['image'] }}" />
<meta property="og:image:width"   content="640" />
<meta property="og:image:height"  content="442" />

这是我的javacript代码

var fbShare = function(url, description, winWidth, winHeight) {
    var winTop = (screen.height / 2) - (winHeight / 2);
    var winLeft = (screen.width / 2) - (winWidth / 2);

    // Try to remove the meta and replace it but its not working
    $('meta[property="og:description"]').remove();
    $('head').append( '<meta property="og:description" content="Testing">' );

    window.open('http://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(url),
        'ListShare',
        'top=' + winTop +
        ',left=' + winLeft +
        ',toolbar=0,status=0,width='+ winWidth +
        ',height='+ winHeight);
}

此外,我没有任何FB ID,因此我认为我无法使用FB.ui 。或者可以在没有appid的情况下使用FB.UI从他们的网站上说它需要HERE

0 个答案:

没有答案