2012-08-29 2 views
-1

최근 페이스 북 API를 자바 스크립트 SDK를 사용하여 연결하려고 시도했습니다. 일부는 크롬을 사용하여 문제가 발생했습니다.이 유형의 오류가 발생했을 수 있습니다.Facebook 자바 스크립트 SDK 연결 문제

: 난 .. 다시하고 다시 새로 고침 계속 비 정지 Facebook에 연결하면 내가 .. 해당 탭을 닫을 필요 내가 모질라 체크

이 문제가 발생할 수 있습니다 무엇인지 잘 모릅니다 그리고 그 후 .. 잘 작동 나는 크롬에 다시 시도해 보았다. 여전히 같은 문제가있다.

백엔드

<?php if(!defined('DOCROOT')) exit('No directory browsing allowed!'); 
class fb_connect extends Frontend{ 

    private $allow_post = true; 
    private $allow_get = true; 

    function __construct(){ 
     parent::__construct(); 

    } 

    function index(){ 

     $facebook = new Facebook(array(
      'appId' => FBAPPID, 
      'secret' => FBSECRETID, 
     )); 

     $user = $facebook->getUser(); 
     $outx = NULL; 
     if ($user) { 
      try { 
       $user_profile = $facebook->api('/me'); 
       $output['user_profile'] = $user_profile; 
      } catch (FacebookApiException $e) { 
       $user = null; 
      } 
     } 
     $output['user'] = $user; 

     $this->tpl->contents['fb'] = $this->tpl->fetch('contents/fb_connect',$output); 

     $this->tpl->meta['title'] = "Facebook Connect Test"; 
     //$this->tpl->meta['description'] = $this->lang['contact_meta_description']; 
     //$this->tpl->meta['keywords'] = $this->lang['contact_meta_keywords']; 
     $this->tpl->render('layouts/default'); 
    } 
} 
?> 

**는 **

<?php if ($user) : ?> 
     Your user profile is 
     <pre> 
     <?php print htmlspecialchars(print_r($user_profile, true)) ?> 
     </pre> 
     <a onclick="FB.logout();">Logout</a> 
    <?php else : ?> 
     <fb:login-button></fb:login-button> 
    <?php endif; ?> 


    <script> 
     window.fbAsyncInit = function() { 
     FB.init({ 
      appId: '<?php echo FBAPPID; ?>', 
      cookie: true, 
      xfbml: true, 
      oauth: true 
     }); 
     FB.Event.subscribe('auth.login', function(response) { 
      window.location.reload(); 
     }); 
     FB.Event.subscribe('auth.logout', function(response) { 
      window.location.reload(); 
     }); 
     }; 
     (function() { 
     var e = document.createElement('script'); e.async = true; 
     e.src = document.location.protocol + 
      '//connect.facebook.net/en_US/all.js'; 
     document.getElementById('fb-root').appendChild(e); 
     }()); 
    </script> 
+0

무한 루프가있는 것 같습니다. 코드를 게시하십시오. –

+0

@paul 내가 사용중인 코드가 추가되었습니다. –

답변

0

왜 들었어?

FB.Event.subscribe('auth.login', function(response) { 
    window.location.reload(); 
}); 
FB.Event.subscribe('auth.logout', function(response) { 
    window.location.reload(); 
}); 

FB.Event.subscribe (EVENT 함수 (...)는 {...}) EVENT가 트리거 될 때마다 트리거된다. 무한 루프가 있습니다. 해당 블록의 console.log()는 한 번만 트리거되지만 전체 페이지를 다시로드하면 이벤트가 다시 트리거됩니다.