views:

35

answers:

1

I have added this code on the top of my PHP script:

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"&gt;&lt;/script&gt;
<script>


FB.init({appId: 'myAppId', status: true, cookie: true, xfbml: true});

FB.login(function(response) {
  if (response.session) {
    if (response.perms) {
      // user is logged in and granted some permissions.
      // perms is a comma separated list of granted permissions
    } else {
      // user is logged in, but did not grant any permissions
    }
  } else {
    // user is not logged in
  }
}, {perms:'read_stream,publish_stream,offline_access'});



</script>

But it doesn' t work !! Why ??

A: 

Facebook doesn't allow conventional JavaScript in canvas applications.

If you're using PHP, try the REST API which has methods for obtaining extended permissions. For example, in my global include file I have the following line:

// require login
$user = $facebook->require_login('read_stream,publish_stream,offline_access');

This only permits access to my application if the user grants me the specified extended permissions.

Hope this helps.

Martin Bean
I have added this on the top of PHP script:require_once('facebook.php');$facebook = new Facebook('xxx','yyy');$fb_user = $facebook->require_login('read_stream,publish_stream,offline_access,email');and the permissions doesn't work :(
xRobot
Are you using the old REST API, or the new Graph API?
Martin Bean

related questions