Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using FB.ui to post to Page wall

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 {

     }
   }
 );
like image 407
jchapa Avatar asked Jan 09 '11 00:01

jchapa


2 Answers

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 {

    }    
   }  
);
like image 141
jchapa Avatar answered Oct 20 '22 01:10

jchapa


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.

like image 40
Damodaran Avatar answered Oct 19 '22 23:10

Damodaran