2012-08-02 6 views
0

facebook app에서 javascript를 통해 초대 친구 요청을하는 데 문제가 있습니다. 내 코드는 다음과 같습니다 당연히Facebook 초대 친구 요청 javascript

<div id="fb-root"></div> 
    <script> 
       $(function() { 
     FB.init({ 
      appId  : '<?php echo APP_ID;?>', // App ID 
      status  : true, // check login status 
      cookie  : true, // enable cookies to allow the server to access the session 
      xfbml  : true, // parse XFBML 
      frictionlessRequests : true, 
     }); 
     FB.Canvas.setAutoGrow(); 
        function sendRequestViaMultiFriendSelector(){ 
         FB.ui({method: 'apprequests', 
          message: 'My Great Request DONALD' 
         }); 
        } 
       }); 
    </script> 

, 내가 가져온 JS SDK를 통해 :

<script src="http://connect.facebook.net/en_US/all.js"></script> 

내가 친구 초대하기 버튼 바인더 제본 : 내 페이지에서

$('.step2').children('.tasto').click(function(){ 
    //sendRequestViaMultiFriendSelector(); 
    console.log("Gooby pls"); 
}); 

을, 콘솔에서이 오류를 만듭니다.

Unsafe JavaScript attempt to access frame with URL http://apps.facebook.com/termapp/ from frame with URL https://s-static.ak.facebook.com/connect/xd_arbiter.php?version=9#channel=f25e11b77&origin=http%3A%2F%2Fwww.termapp.test&channel_path=%2F%3Ffb_xd_fragment%23xd_sig%3Df3245a897%26. Domains, protocols and ports must match. 

당연히 버튼이 작동하지 않습니다.

저는 Chrome에 있으며 제 사이트는 Zend와 함께 php로 만들어졌습니다. 가상 호스트에 있기 때문에 응용 프로그램을 표시 할 수 없습니다.

+0

을 나는 그것이 생각 크롬 문제! 내가 어떻게 고칠 수 있니? –

답변

0

FB가 권장하는 방식으로 all.js 파일을로드하지 않습니다. 여기에 문서를 살펴 보자 :

https://developers.facebook.com/docs/reference/javascript/

를 해당 페이지가 비동기 API를로드 제안 :

<div id="fb-root"></div> 
<script> 
    window.fbAsyncInit = function() { 
    FB.init({ 
     appId  : 'YOUR_APP_ID', // App ID 
     channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File 
     status  : true, // check login status 
     cookie  : true, // enable cookies to allow the server to access the session 
     xfbml  : true // parse XFBML 
    }); 

    // Additional initialization code here 
    }; 

    // Load the SDK Asynchronously 
    (function(d){ 
    var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; 
    if (d.getElementById(id)) {return;} 
    js = d.createElement('script'); js.id = id; js.async = true; 
    js.src = "//connect.facebook.net/en_US/all.js"; 
    ref.parentNode.insertBefore(js, ref); 
    }(document)); 
</script> 

채널 파일에 대한 자세한 내용은 설명서를 참조 등