Wie kann ich meine Facebook-Anwendung dazu bringen, nach der Installation automatisch nach den erforderlichen Berechtigungen zu fragen?

Ich benutze das Facebook PHP SDK (2.1.2). Alles was ich machen möchte ist, was fast jede Facebook-Anwendung mit @ macreq_perms hat. Das blöde "Request for Permissions" -Feld erscheint, wenn Sie es installieren.

Ich möchte keine Taste, die der Benutzer drücken muss. Ich möchte nicht, dass ein Popup erscheint. Ich möchte FBML nicht verwenden,since sie machen damit Schluss.

Dies ist das Standarddialogfeld für Facebook-Berechtigungen, in dem angezeigt wird, wo meine Anwendung im Erstellungsbereich iframe angezeigt werden soll.

Ich habe es versucht

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

Das aus irgendeinem Grund ein Facebook-Logo zeigte, das mit der richtigen URL, die ich wollte, verknüpft war nicht was ich will!)

<?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>"); ?>

Dieses zeigte eine leere Seite.

<?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>

Dies zeigt auch eine leere Seite.

Was ich will, ist nicht unbeliebt, aber die Facebook-Dokumentation ist die schlechteste Dokumentation, die ich je gesehen habe. Nichts funktioniert. Etwas so idiotisch Einfaches sollte nicht zwei Tage dauern, um es herauszufinden.

Hier ist die Lösung, mit der ich gelandet bin:

<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>

Antworten auf die Frage(2)

Ihre Antwort auf die Frage