0

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"></script>
<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 ??

xRobot
  • 25,579
  • 69
  • 184
  • 304
  • 2
    What doesn't work? What happens or doesn't happen? Any error messages? – Pekka Jun 23 '10 at 10:06
  • It ask request for this only permission: Access my basic information Includes name, profile picture, gender, networks, user ID, list of friends, and any other information I've shared with everyone. – xRobot Jun 24 '10 at 07:22

1 Answers1

0

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
  • 38,379
  • 25
  • 128
  • 201
  • 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 Jul 11 '10 at 09:50
  • Are you using the old REST API, or the new Graph API? – Martin Bean Jul 12 '10 at 09:59