문제

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 {

     }
   }
 );
도움이 되었습니까?

해결책

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 {

    }    
   }  
);

다른 팁

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.

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
});

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);
}());

Sorry, this is an old question, but I thought this might be helpful for people who find it via google. http://fbmhell.com/2011/07/facebook-share-popup-iframe-tabs-jquery/

Just remember target_id needs to be parsed into an int. The response["to"] comes back as a string.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top