1
votes

Usecase - I have my web application and I want to post some data from my application onto my Facebook wall manually when a user clicks on a Link.

I'm currently using Share Link as follows -

https://www.facebook.com/sharer/sharer.php?u=&t=titleABC" target="_blank"> Share on Facebook

Issue - I see that a new window opens to post the data. My data also gets posted to my wall, but I want the title to be populated with data from my application rather than asking the user to "Write Something".I want the text box to get populated with the message from the title(t from the url parameter) rather than user editable. Is there a way to do this.

1

1 Answers

3
votes

Sharing your content with Share button is absolutely simple. In my case I did it like this for a button i have in my html with id sharebuttonfacebook

$("#sharebuttonfacebook").click(function() {
  var msg = "Hi This is my wonderful website";
  FB.ui({method: 'feed',
  name: 'MCQ Nation ', 
  link: 'http://www.mcqnation.com/Trail3/pyramid.php?..dyanmic stuff..' , 
  picture: 'http://www.mcqnation.com/Trail3/fbapp2.png', 
  caption:'CLICK ON THE IMAGE TO GO TO OUR WEBSITE', 
  description: msg , 
  message: 'AAA'});
  return false;
});

In addition to this you need to register an app. Nothing could be simpler. Just go to http://www.facebook.com/developers/app and register your new app.

They will give you a simple code that has to be put just after the body which goes like -

<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : 'YOUR_APP_ID', // App ID
      channelUrl : 'CHANNEL FILE LOCATION', // Channel File This file has just one line which you will find at facebook developers
      status     : true, // check login status
      cookie     : true, // enable cookies to allow the server to access the session
      xfbml      : true  // parse XFBML
    });
</script>

With these two things in place you can Decide what to share on facebook.

Also in the function we have made above you can substitute whatever variables you like hence make it dynamic. Hope this answers your Question.

PS: If it could get better than this you dont need any permission from the user!