Using FB.ui to post to Page wall

32,839

Solution 1

Got it:

you have to set the to and from values:

FB.ui(    {
  method: 'feed',
  name: name,
  link: link,
  picture: picture,
  caption: caption,
  description: redemption,
  message: message,
  to: page_id,
  from: page_id    
 },    
function (response) {
    if (response && response.post_id) {
      alert(response.post_id);
    } else {

    }    
   }  
);

Solution 2

I used the JavaScript SDK to post on user's wall:

function graphStreamPublish(){
           var body = document.getElementById("txtTextToPublish").value;
            FB.api('/me/feed', 'post', { message: body }, function(response) {
                if (!response || response.error) {
                     alert('Error occured');
                } else {
                     alert('Post ID: ' + response.id);
                }
           });
     }

When I go through the Graph API Page I think if you change '/me/feed/' to 'pageId/feed' then it may post the message in that page. I am not sure. - just a suggestion.

Solution 3

To share on a friend's wall, as of February 2012:

FB.ui({
    method: 'stream.publish',
    app_id: appId,
    display: 'iframe',
    name: name,
    link: link,
    picture: picture,
    caption: caption,
    description: description,
    target_id: friendIds
});

Solution 4

To post to facebook wall use the following.. .

Call the below js function using simple call as in below

<a href="#" onclick="publishWallPost()">Post to Wall image/text?</a> 


//facebook: post to wall 
function publishWallPost() {

      FB.ui({
          method: 'feed',
          name: 'Your App Name',
          caption: 'Caption Text',
          description: 'Your description text',
          link: 'https://www.facebook.com/link/link.link',
          picture: fbImg
        },
        function (response) {
          console.log('publishStory response: ', response);
        });
      return false;
}


window.fbAsyncInit = function () {
      FB.init({
        appId: 'Your App ID',
        status: true,
        cookie: true,
        xfbml: true
      });
};

(function () {
      var e = document.createElement('script');
      e.async = true;
      e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
      document.getElementById('fb-root').appendChild(e);
}());
Share:
32,839

Related videos on Youtube

jchapa
Author by

jchapa

Full stack LAMP and .NET developer.

Updated on July 09, 2022

Comments

  • jchapa
    jchapa almost 2 years

    I'm using FB.ui to post to a Facebook user wall. However, I am uncertain on which parameters to use to post to a Page or Application wall. Any links?

    I am trying to post to the Page wall as that page, not as the user's account.

    Code to post to user account:

     FB.ui(
       {
         method: 'feed',
         name: name,
         link: link,
         picture: picture,
         caption: caption,
         description: redemption,
         message: message
       },
       function (response) {
         if (response && response.post_id) {
           alert(response.post_id);
         } else {
    
         }
       }
     );
    
  • jchapa
    jchapa over 13 years
    Yeah, I tried that. I was looking for the FB.ui popup, though. :-)
  • Plastic Sturgeon
    Plastic Sturgeon almost 13 years
    This code does not work. (Unless the user has liked the page first) also the feed from dialog is a special case that only works for page administrators. developers.facebook.com/docs/reference/dialogs/feed
  • snipe
    snipe over 12 years
    If you check out the link I posted above, it shows you how to get the popup using jquery+FB.ui.
  • Auguste Van Nieuwenhuyzen
    Auguste Van Nieuwenhuyzen over 12 years
    This doesn't work for me, either - I set the from and to to be the page's ID - I'm impersonating that page on Facebook but get the error:
  • superscral
    superscral almost 12 years
    stream.publish going to be deprecated, isn't it?
  • NaturalBornCamper
    NaturalBornCamper almost 12 years
    Yes it is unfortunately, didn't check yet for the new solution, I will when I need it again.
  • haskovec
    haskovec almost 12 years
    The problem with this code is it shows up to publish to a user's wall. The question is how to use FB.ui to publish to an application page which is not the same thing.
  • snipe
    snipe over 10 years
    The reply is 2 years old - not sure it warrants a -1 for that. Anyway, the updated link is here: snipe.net/2011/07/facebook-share-popup-iframe-tabs-jquery

Related