user1405338
user1405338

Reputation: 189

javascript facebook publish on the wall

there are many answer on this issue, but I can't find the right solution! I have javascript that calls the login, but with no premission to post to the wall

window.fbAsyncInit = function() {
    FB.init({
      appId: '<?php echo $this->getAppID; ?>',
      cookie: true,
      xfbml: true,
      oauth: true
    });
    FB.Event.subscribe('auth.login', function(response) {
      window.location.reload();
    });
    FB.Event.subscribe('auth.logout', function(response) {
      window.location.reload();
    });
  };
  (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);
  }());

In the php code it is very simpel added in the array like:

 $facebook->getLoginUrl(array(
'scope' => 'publish_stream'                                         ));

but how can I add it to the javascript button this url to ask permission to post to the wall of the user

Upvotes: 0

Views: 379

Answers (1)

Yan Berk
Yan Berk

Reputation: 14438

You ask for permissions using the scope parameter:

FB.login(function(response) {
   alert(response);
 }, {scope: 'email,user_likes'});

Read more:

EDIT:

Javascript:

function login() {
FB.login(function(response) {
   alert(response);
 }, {scope: 'email,user_likes'});
}

HTML:

<div onclick="login();return false;">click here to login</div>

Upvotes: 1

Related Questions