Take the 2-minute tour ×

I've been Googling for 2 days, and can't find anything definitive. All results I've come across use deprecated code that no longer works. Please help.

I need a button that on click...

  1. Checks for extended permissions
  2. If permissions are not already granted, request them (user_likes, offline_access, publish_stream)
  3. After getting permissions, publish post to user's wall
  4. Allow me to push wall posts to users while they are offline

Can someone please assist?

share|improve this question
Thanks to OffBySome for this example. Looking at it, I can see that I was very close to the solution, but missed the FB.login inclusion with response.authResponse. I will implement this tonight, and report my findings. –  Steve Sep 13 '11 at 20:20
With regard to the offline_access, can anyone confirm that this permission is not needed in order to post without user interaction? I understand that this is a bit of a grey area, but the user is aware that this would be taking place, and must specifically choose to allow it. It was my understanding, however, that the ability to post to an offline user's wall required this, as the auto-post: true was disabled. Using the user id, I just need to include the auth token without needing offline_access? –  Steve Sep 13 '11 at 20:22
I implemented the example posted by OffBySome last night, and it worked beautifully. Thank you :) –  Steve Sep 14 '11 at 14:46
add comment

1 Answer

up vote 5 down vote accepted

It's pretty simple. You can call FB.login to get extended permissions. Then you can call FB.ui to post a status (or FB.api to call /me/feed to post without user interaction, which is frowned upon). To be able to push wall posts at a later date you would need to store the access_token on your server for later use.

<!DOCTYPE html>
<a href="#" onclick="return postToWall();">Post To Wall</a>
  FB.init({ appId: '**appID**', status: true, cookie: true, xfbml: true, oauth: true });

  function postToWall() {  
    FB.login(function(response) {
      if (response.authResponse) {
            method: 'feed', 
            name: 'Facebook Dialogs',
            caption: 'Reference Documentation',
        function(response) {
          if (response && response.post_id) {
            alert('Post was published.');
          } else {
            alert('Post was not published.');
      } else {
    }, {scope: 'user_likes,offline_access,publish_stream'});
    return false;
share|improve this answer
Note that the OAuth2 migration date is Oct 15 and all apps will be required to use OAuth2 after that. To enable that you need to add oauth: true to the FB.init call and change perms to scope. –  steveax Sep 13 '11 at 6:04
@steveax: you're right. i forgot and grabbed an old example I had. i updated the example. –  bkaid Sep 13 '11 at 6:28
Good deal, might also want to make the call to FB library protocol agnostic: <script src="//connect.facebook.net/en_US/all.js"></script> given the upcoming SSL requirements. –  steveax Sep 13 '11 at 7:10
again, you don't need the offline_access permission to be able to post when the user is offline the publish_stream and the user id is enough! –  ifaour Sep 13 '11 at 8:41
I know this but he said he needed it in his question. –  bkaid Sep 13 '11 at 14:03
show 1 more comment

Your Answer


