2013-10-30 8 views
-5

나는 facebook-invite-friends-api에서 페이스 북의 초대 상자를 구현했다. 그러나 (9lesson) 페이스 북 알림 데모에서 보여준대로 내 웹 사이트로 리디렉션하는 방법을 얻을 수 없다. 어떻게 도와 드릴까요?facebook 앱에서 내 웹 사이트로 리디렉션하는 방법은 무엇입니까?

내 코드는 다음과 같습니다

<div id="fb-root"> 
</div> 
<a href="javascript:void(0);" onclick="FbRequest('If you want to fulfill your wishes then do not miss the opertuanty, huury up and join WishIsDone, A platform where you can fulfill your as well as your friends wishes...!','609416079110673');"> 
    Send Request</a> 
<script type="text/javascript"> 
    function FbRequest(message, data) { 
     FB.ui({ method: 'apprequests', message: message, data: data, title: 'Share this site with your friends' }, 
      function (response) { 
       // response.request_ids holds an array of user ids that received the request 
       var receiverIDs; 
       if (response.request) { 
        var receiverIDs = response.to; // receiverIDs is an array holding all user ids 
        alert(receiverIDs); 
       } 
      } 
    ); 
    } 
    // typical application initialization code for your site 
    (function() { 
     var e = document.createElement('script'); 
     e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; 
     e.async = true; 
     document.getElementById('fb-root').appendChild(e); 
    }()); 
    window.fbAsyncInit = function() { 
     FB.init({ 
      appId: '******', 
      session: {}, 
      status: true, 
      cookie: true, 
      xfbml: true 

     }); 
    }; 

</script> 

내 로그인 페이지 코드 : 초대 중 하나에 사용자가 클릭이, 그들은 응용 프로그램의 캔버스 URL로 전송됩니다

기본적으로
<script type='text/javascript'> 
    if (top.location != self.location) { 
     top.location = self.location 
    } 
</script> 

답변

3

. 애플리케이션 설정에서 설정 한 것.

사용자가 응용 프로그램으로 전송됩니다 거기에서 당신은 자바 스크립트가 튜토리얼처럼 당신이 링크 리디렉션 사용하여 실제 사이트로 리디렉션 할 수 있습니다 :

다음 코드 Iframe에 속보입니다 귀하의 웹 페이지에이 코드를 포함하십시오.

<script type='text/javascript'> 
if (top.location!= self.location) 
{ 
top.location = self.location 
} 
</script> 

그들이 iframe을하고 그것으로 내용을 의미 "iframe이 파괴"라고

실제 URL입니다 (바보 표현 ... 동의). top.location을 사용합니다. 최상위 프레임의 위치가 변경됩니다.이 경우에는 apps.facebook.com입니다.

+0

위의 코드를 로그인 페이지에 추가했지만 필요한 결과를 얻을 수 없습니다. –

+0

콘솔에 JS 오류가 있습니까? 사용자가 실제로 로그인 페이지에 도착합니까? – Lix

+0

나는 그걸 확인하기 위해 경보를 사용했으나 화재 경보도 있습니다. 그래서 로그인 페이지에 도착한다고 말할 수는 없지만 그것을 내 웹 사이트의 기본 페이지로 설정했습니다. 캔버스 URL을 다음과 같이 입력했습니다 :: http://subdomain.domian.com/foldername/ –