0
votes

Created a facebook application and a fan page tab which is rendering my site.

How can I create and share a post on User's wall using facebook API.

Thanks in Advance.

1
You're not clear at all!! What exactly you want to do mention that.Sahil Mittal
@Sahil Please Read my question carefully I am little bit confusedChirag Shah
You're confused because your concepts are not clear. You cannot create an app which works as page.. and its unclear what are you trying to say regarding this sharing thing. Sorry but I think nobody here is willing to understand this questionSahil Mittal
@sahil I have updated my question please see it and try to give me answer.Chirag Shah
You just want to publish a post on user's wall from the app? right? Are you using any sdk? Have you tried anything yet?Sahil Mittal

1 Answers

4
votes

You can simply use /me/feed-

window.fbAsyncInit = function() 
{
    FB.init({
        appId      : '{app-id}',
        status     : true,
        cookie     : true,
        xfbml      : true 
    });

    FB.login(function(response){
        if (response.authResponse) {
            Share(); 
        } else {
            // The person cancelled the login dialog
        }
    },{scope: 'publish_actions'});

};

// Load the SDK asynchronously
(function(d){
 var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
 if (d.getElementById(id)) {return;}
 js = d.createElement('script'); js.id = id; js.async = true;
 js.src = "//connect.facebook.net/en_US/all.js";
 ref.parentNode.insertBefore(js, ref);
}(document));

function Share(){
   FB.api(
      "/me/feed",
      "POST",
      {
          "object": {
              "message": "This is a test message",
              "link": "{link}",
              "description": "{description}"
          }
      },
      function (response) {
         if (response && !response.error) {
            // success
         } 
      }
   );
}

Permissions required: publish_actions