Using Facebook Graph to simply post a wall message with just javascript

Active3 hr before
Viewed126 times

3 Answers


In Facebook how can I post a message onto a user's wall saying "I scored 8/10 on objects game" then a URL?,Is it possible using the new Graph API and JavaScript?, Bayesian analysis used merely as a computational tool? ,I really don't want to have to use the full API, as I don't want to handle user login details. I don't mind if Facebook needs to authenticate and then post the message.

You can use something like this to publish to a wall, the user will need to confirm before it get sent. Don't forget that you'll need to use FB.init and include the JS SDK link.

 function fb_publish() {
          method: 'stream.publish',
          message: 'Message here.',
          attachment: {
             name: 'Name here',
             caption: 'Caption here.',
             description: (
                'description here'
             href: 'url here'
          action_links: [{
             text: 'Code',
             href: 'action url here'
          user_prompt_message: 'Personal message here'
       function(response) {
          if (response && response.post_id) {
             alert('Post was published.');
          } else {
             alert('Post was not published.');
load more v

Permissions Reference,A Facebook Feed story,Whether or not the post references an app,An array of information about the attachment to the post

GET / v12 .0 / {
   post - id
HTTP / 1.1
load more v

There are two examples there, one using the FB.ui (to show dialog) and the other using FB.api.  The difference is that the FB.api method does not display any user-interface (dialog), so this is best used for canned messages.,This method uses the so-called dialog, which has been present since the Old Legacy API. To call this in the Graph API, use FB.ui like below:,The result looks like this. Notice the blank vertical gray bar on the left side which is the default image because we did not put any picture in the post. To post with picture, continue to the second part of this guide, which is linked at the bottom of this article.,Facebook has some policies of what kind of message you can put in the message field, read about it here: under Platform Policies in message section.

This methods uses the /userId/feed Graph API where userId is the numeric user id of the target (applications can post to the user or the user’s friends wall but not strangers). If you want to post to the wall of the logged in user, you can also use /me/feed. Again, when using this, the posting is done in passive mode (user will not get prompted to enter a message unless you provide your own forms).

FB.api("/userId/feed", 'post', data, callbackFunction);
load more v

Other "facebook-using" queries related to "Using Facebook Graph to simply post a wall message with just javascript"