简体   繁体   中英

How to post to an Authorised User (with extended permissions) wall - Facebook JS SDK + Graph API

I know this question has been asked a thousand time, but I have yet to come across a definitive answer.

How does an application (external website, so no fbml) post to a users wall, using JS and Graph API?

I have established extended permissions with users, and can post to walls using Facebooks sample code, however the variables within the script wont appear on FB.

For Example:

    function publish_test(){
    var body = 'Reading Connect JS documentation';
FB.api('/me/feed', 'post', { body: body }, function(response) {
  if (!response || response.error) {
    alert('Error occured');
  } else {
    alert('Post ID: ' + response);
  }
});
}

This posts to the users wall, however it does not contain the body. Any help on this would be gratefully appreciated.

FB.ui will pop up a confirmation dialog to the user, not sure if you want that or not. http://developers.facebook.com/docs/reference/javascript/FB.ui

This page has documentation about the FB.api call: http://developers.facebook.com/docs/api Scroll down to the "Publishing" section and notice that there's no "body" parameter specified. There is a "message" parameter though. The other example you're looking at is probably incorrect?

我让这段代码正常工作

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM