Api facebook我无法获得所有信息

时间:2013-10-08 11:20:49

标签: php facebook facebook-javascript-sdk facebook-php-sdk

我会收到我的应用程序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申请

我在我的页面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

中有这个

1 个答案:

答案 0 :(得分:0)

您必须在配置中添加此内容

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

    });