How to make the Facebook application automatically request the required permissions after installation

I am using the PHP PHP SDK (2.1.2). All I want to do is what almost every Facebook application has with req_perms. The stupid "permission request" checkbox appears when it is installed.

I do not need a button that the user must click. I do not want to pop up. I do not want to use FBML since they eliminate it .

This is a standard Facebook permissions dialog that shows where my application should appear in a canvas iframe.

I tried:

<?php if(!$me): ?>
    <head>
        <meta HTTP-EQUIV="REFRESH" content="0; <?php echo $loginUrl; ?>">
    </head>
<?php die(); ?>
<?php endif; ?>

This for some reason showed the Facebook logo associated with the correct URL that I wanted (not what I want!)

<?php if($me): ?>
    window.fbAsyncInit = function() {
        FB.init({
            appId   : '<?php echo $appid; ?>',
            session : <?php echo isset($session) ? "'".json_encode($session)."'" : 'null'; ?>, // don't refetch the session when PHP already has it
            status  : true, // check login status
            cookie  : true, // enable cookies to allow the server to access the session
            xfbml   : true // parse XFBML
        });

        // Whenever the user logs in, we refresh the page
        FB.Event.subscribe('auth.login', function() {
            window.location.reload();
        });
    };

    (function() {
        var e = document.createElement('script');
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
    }());
 </script>
 <fb:redirect url="<?php echo $loginUrl; ?>" />
 <?php die("</html>"); ?>

There was a blank page on this page.

<?php if($me): ?>
    window.fbAsyncInit = function() {
        FB.init({
            appId   : '<?php echo $appid; ?>',
            session : <?php echo isset($session) ? "'".json_encode($session)."'" : 'null'; ?>, // don't refetch the session when PHP already has it
            status  : true, // check login status
            cookie  : true, // enable cookies to allow the server to access the session
            xfbml   : true // parse XFBML
        });

        // Whenever the user logs in, we refresh the page.
        FB.Event.subscribe('auth.login', function() {
            window.location.reload();
        });
    };

    (function() {
        var e = document.createElement('script');
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
    }());
 </script>
 <script>
     FB.login(function(response) {
         if (response.session) {
             if (response.perms.indexOf('publish_stream') != -1) {
                 //User has logged in and given us publish_stream permissions
             );
             else {
                 //User has logged in but not given us publish_stream
             }
         }
         else {
             //User is not logged in
     }, {perms:'offline_access,publish_stream'});
 </script>

A blank page is also displayed here.

, , , Facebook - , - . . -, , .

:

<div id="fb-root"></div>
<script>
    window.fbAsyncInit = function() {
        FB.init({
            appId   : '<?php echo $appid; ?>',
            session : <?php echo isset($session) ? "'".json_encode($session)."'" : 'null'; ?>, // don't refetch the session when PHP already has it
            status  : true, // check login status
            cookie  : true, // enable cookies to allow the server to access the session
            xfbml   : true     // parse XFBML
        });

        FB.getLoginStatus(function(response) {
            if (response.session) {
                // Logged in and connected user, someone you know.
            } else {
                // No user session available, redirect them to login.
                window.top.location = "<?php echo $loginUrl; ?>";
            }
        });

        // Whenever the user logs in, we refresh the page.
        FB.Event.subscribe('auth.login', function() {
            window.location.reload();
        });
    };

    (function() {
        var e = document.createElement('script');
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
    }());
</script>
+2
1

, PHP SDK URL- , JavaScript URL-. http://github.com/facebook/php-sdk/blob/master/examples/example.php , . , . , , .

<script>
    FB.getLoginStatus(function(response) {
        if (response.session) {
            // Logged in and connected user, someone you know.
        } 
        else {
            // No user session available, redirect them to login.
            window.top.location = <?php echo $loginUrl; ?>
        }
    });
</script>
0

All Articles