Multiple share button on the same page in facebook iframe application

Tag: facebook Author: boningdai Date: 2009-07-15

I have an facebook iframe application. Now i want to give multiple share functionality on a same page. For e.g. there is a topic page in which list of topics is displayed. For each topic i want to give a share button.

I am using a code http://www.facebook.com/share_partners.php.

Please guide me how can i provide multiple share functionality and can i change the custom text of Comment · Like· Share when posted on profile page?

Thanks

Other Answer1

I know this questoion is old but I had the same problem recently when shifting a clients Facebook Page tab from fbml to iframe. Hopefully someone might find it useful.

You need to use the Facebook javascript api, check it out here:

http://developers.facebook.com/docs/reference/javascript/

and scroll down to the Dialogs heading

Heres an example in php:

<?php foreach($rows as $row) { ?>

Your stuff, blah blah

<script type="text/javascript">
function share_<?php echo $row['id']; ?>() { FB.ui(
  {
    method: 'stream.publish',
    attachment: {
      name: 'Static text: <?php echo $row['title']; ?>',
      caption: 'Static text: <?php echo $row['title']; ?>',
      description: (
        '<?php 
        echo $row['desc'];
        ?>'
      ),
      href: 'http://somedomain.com/blah.php?id=<?php echo $pro['id']; ?>'
    },
    action_links: [
      { text: 'fbrell', href: 'http://somedomain.com/blah.php?id=<?php echo $pro['id']; ?>' }
    ]
  },
  function(response) {
    if (response && response.post_id) {
      alert('Post was published.');
    } else {
      alert('Post was not published.');
    }
  }
);
return false;
}
</script>
<a href="#" onclick="return share_<?php echo $row['id']; ?>()"> <img src="<?php echo SITE_URL . 'images/share_thin.jpg' ?>" /> </a>
<?php } ?>

comments:

NB! If you plan to use this code, please make sure to sanitize and/or escape the variables to avoid XSS problems.

Other Answer2

You can do this in a couple of ways:

Actually Facebook recommends using Like Button. You really can do great things with usage of open-graph tags to represent every of your topics in user's feed.