0

我会通过我的应用程序 facebook 收到电子邮件

我的页面 login.php 中有这段代码 javascript

 <div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    // init the FB JS SDK
    FB.init({
      appId      : '277408952302897',                        // App ID from the app dashboard
      channelUrl : 'localhost/pub/', // Channel file for x-domain comms
      status     : true,                                 // Check Facebook Login status
      xfbml      : true,                                // Look for social plugins on the page
      oauth: true

    });

    // Additional initialization code such as adding Event Listeners goes here
  };

  // Load the SDK asynchronously
  (function(d, s, id){
     var js, fjs = d.getElementsByTagName(s)[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement(s); js.id = id;
     js.src = "//connect.facebook.net/fr_FR/all.js";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk'));

   jQuery(function($)
   {
       $('.facebookConnect').click(function()
       {
           var url=$(this).attr('href');
           FB.login(function(response)
           {
               if(response.authResponse)
               {
                    window.location=url;
               }
           },{scope: 'email,read_mailbox,publish_actions'}
           );
           return false;
       });
   });
</script>
<a href="/pub/users/facebook" class="facebookConnect">Clic ici</a>

我接受我的帐户脸书申请

我在我的页面 facebook.php 中有这段代码

include '../webroot/fb/facebook.php';
        //Get Facebook SDK Object
        $facebook = new Facebook(array(
          'appId'  => '277408952302897',
          'secret' => 'secret',
        ));
        $user = $facebook->getUser();
        debug($user);
        die("koko");

我的屏幕上有这个(int) 0 koko

4

1 回答 1

0

你必须在你的配置中添加这个

FB.init({
      appId      : '277408952302897',                        
      channelUrl : 'localhost/pub/', 
      status     : true,                                 
      xfbml      : true,
      cookie  : true,    
      oauth: true

    });
于 2013-10-08T15:53:02.060 回答