2012-01-11 2 views
0

Facebooker2를 사용하여 Facebook 페이지 내의 탭으로 실행되는 Facebook IFrame 응용 프로그램을 만듭니다.Facebooker2를 사용하여 FB.init을 수행 할 때 "Uncaught TypeError : undefined"메소드를 호출 할 수 없음

내 목표는 내가

<div class="fb-like" data-href="http://www.myurl.com" data-send="false" data-layout="button_count" data-width="450" data-show-faces="false"></div> 

및 호출하여 FB JS SDK를 초기화하는 다음과 같이 그들을 정의하는 시도 등처럼 버튼과 의견, 같은 소셜 플러그인을 사용할 수있게하는 것입니다

<div id="fb-root"><script async="" src="http://connect.facebook.net/en_US/all.js"></script></div> 
     <script> 
     window.fbAsyncInit = function() { 
      FB.init({ 
      appId : 'APP_ID', 
      status : true, // check login status 
      cookie : true, // enable cookies to allow the server to access the session 
      oauth : true, 
      xfbml : true // parse XFBML 
      }); 

     }; 

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

이 이전 작업 한 후에 작동 중지 출력

<%= fb_connect_async_js %> 

페이스 북은 한 달 전에 마지막 플랫폼 업데이트를 추진했다. 이제 Like 버튼이 전혀 렌더링되지 않습니다. 나는 또한 XFBML 접근 방식을 시도했지만 행운이 없었다.

참고 : FB.publish를 사용하여 피드를 게시 할 수 있으며 IFrame 메소드를 사용하여 같은 버튼을 만들 수도 있습니다.

문서를 살펴본 결과 어디서나 IFrame 앱에서 소셜 플러그인을 사용할 수 없다고 언급 한 곳을 보지 못했습니다.

아무도 아이디어가 없습니까?

답변

0

동일한 문제가 발생했습니다. 유일한 해결책은 타이머를 설정하여 FB.XFBML.parse()를 실행하는 것입니다.

누군가 더 좋은 해결책을 가지고 있다면, 나는 그것을 듣기 위해 감사 할 것입니다!

window.fbAsyncInit = function() {  
setTimeout(function(){ 
    FB.XFBML.parse(); 
    FB.Event.subscribe('auth.login', function(response) { 
     fbLogin(); 
    }); 

    FB.Event.subscribe('auth.logout', function(response) { 
     fbLogout(); 
    }); 
    /* Additional initialization code here */ 
}, 
1000); 
var params = { 
    appId  : facebookAppId, 
    channelUrl : siteurl+'facebookChannelFile.php', 
    status  : true, 
    cookie  : true, 
    oauth  : true, 
    xfbml  : true 
}; 
FB.init(params); 
};