Dynamic setting FB Sharer og:description

73 views Asked by At

Hi I would like to do a page sharing of multiple item using fb sharer. But from what I understand is that I need to put the description and title on the meta tag. But what if I want it to be dynamic? Let say for example I click on an item and based on the item I click the fb sharer popup will appear and displaying the details of the item I clicked. Is this even possible? Right now below is my code

<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" />

And this is my javacript code

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);
}

Also I don't have any FB ID so I think I can't use FB.ui for this.Or is it possible to use FB.UI without the appid since from their site it says that it's required HERE

0

There are 0 answers