Multiple Facebook Shares on One Page

13,645

why are you taking this approach? i recommend using either the social widgets or the javascript sdk fb provides.

for example, with the js sdk you can do this: https://developers.facebook.com/docs/reference/dialogs/send/

as for the social widgets, you can add a like for each item: https://developers.facebook.com/docs/reference/plugins/like/

or send button: https://developers.facebook.com/docs/reference/plugins/send/

Share:
13,645
Curtis Mangione
Author by

Curtis Mangione

Updated on October 25, 2022

Comments

  • Curtis Mangione
    Curtis Mangione over 1 year

    I have a daily deal aggregator site and i can't get the Facebook share to work properly. There are lots of deals on each page and each one has it's own FB share so they can post it on their wall, friends walls etc.

    here is the site so you can try the share: http://bit.ly/xFGzj5

    Here is the code Im using now:

    <!-- Each Deal has this button that links to FB -->
    <a href="http://www.facebook.com/share.php?u=<?php echo urlencode($shareurl); ?>" onclick="return fbs_click('<?php echo urlencode($shareurl); ?>','<?php echo $title; ?>')" target="_blank"><img src="../../images/fb.png" border="0" alt="Share On Facebook" class="smicon" /></a>
    
    <!--And here is the JS function:-->
    
    <script>
    function fbs_click(u,t) {
    window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
    return false;
    }
    </script>
    

    With this method, right now the title is not working properly, and sometimes an image shows up, sometimes it doesn't. When an image does show there are about 200 thumbnails to choose from (depending on how many deals are on the page) so the user has to cycle through it until they find the right one.

    Ideally, I want the url/title working properly (obviously) and have the image go to that specific deal's image by default when they click the share button. Anyone have any ideas on how to make this work???

  • Curtis Mangione
    Curtis Mangione over 12 years
    Hi Nitzan. Thanks for the reply. I have looked into these widgets a little bit. The first and third one you suggested looks like it can only be shared in a private message. My goal is for users to be able to post to their own timeline or a friends timeline. The like button intrigues me a little bit, but I want to be able to specify the title and image someone shares. I see there are the open graph tools where you can specify this info, but based on that I can only have 1 generic image and 1 generic title for the hundreds of deals that are on my page. Any thoughts? Thanks!
  • Curtis Mangione
    Curtis Mangione over 12 years
    Ya the like button has none of the details I want. All it can do is say a user likes the URL where my deal is. It says nothing on their wall/timeline about the deal title or the image. Is what I want even possible?
  • Nitzan Tomer
    Nitzan Tomer over 12 years
    well, the facebook share button is deprecated (developers.facebook.com/docs/share) and so i strongly advise against using that. as i see it you should either use the like button, or use the js sdk to open up a fb dialog for sharing like here: developers.facebook.com/docs/reference/dialogs/feed
  • Curtis Mangione
    Curtis Mangione over 12 years
    That's perfect!! Thank you very much for your help Nitzan!
  • anubhav16
    anubhav16 about 7 years
    @NitzanTomer I have multiple images and share button in one pages. How do I add custom image to each of share button. FB recommends use of og:image meta tag but it is valid only for one image per image.
  • Nitzan Tomer
    Nitzan Tomer about 7 years
    @anubhav16 Sorry, I have no idea. This answer is more than 3 years old, and I haven't been using any of the fb apis for a few years now. If you can't find your answer on SO, ask it.