vendredi 22 mai 2015

Add Facebook Share Button with Video to Website

I am adding a Facebook Share button to my website. I am able to set it up to include a picture in the post, but I'd like it to include a video. How would I do this using the FB.ui feed parameters?

Here is my working code for adding a picture:

<!-- Facebook share script -->
<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/en_US/sdk.js#xfbml=1&version=v2.3&appId=*********";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

 <div class="fb-share-button" data-href="#{@project_url}" data-layout="icon">
       <%= image_tag "facebook.png", :class=>"social_icon" %>
 </div>

$('.fb-share-button').click(function(e){
    e.preventDefault();
    FB.ui(
        {
        method: 'feed',
        name: "<%=@project.user.username%>",
        link: '<%=@project_url%>',
        picture: '<%=@project.images.first.image_file_url%>',
        caption: ' ',
        description: ' ',
        message: ''
    });
});




Aucun commentaire:

Enregistrer un commentaire