2011-08-03 39 views
0

我想獲取新的用戶惠普Facebook的請求。不幸的是,當用戶接受來自Facebook的邀請時,他被重定向到https://www.facebook.com/?request_ids=xxxxxxxxxxx 而不是我的網站。我嘗試將用戶標識傳遞給Facebook,但我沒有收到任何「回傳」。這是什麼錯我的應用程序?我需要更改應用程序設置或者我的代碼錯誤?Facebook的請求不起作用

 <div id="fb-root"></div> 
    <script src="http://connect.facebook.net/en_US/all.js"></script> 
    <script> 
    function invitefacebook(){ 
     FB.init({appId: 'xxxxxxxxxxxx', xfbml: true, cookie: true}); 
    FB.ui({ 
    method: 'apprequests', 
    message: 'I invite you in this awesome website!', 
    data: '<?php echo $id; ?>'}); 

    } 
    </script> 
<a onclick="invitefacebook();">Invite Friends</a> 

在此先感謝:d

回答

1

即使它重定向到facebook.com,你可以看到你的應用程序無論是作爲一個iframe或作爲URL本身內部的標籤。

所以當您在URL中得到request_ids你應該編寫你的應用程序,這樣你做的東西..

所以做這樣的事情

if(isset($_REQUEST['request_ids'])){ 
//here you can get the current logged in FBuser using you SDK 
//and then just write some code, where you can either store them as 
//accepted invitation in db or anything as you wish. 
} 

上面的代碼應該存在於頁,其中將在用戶重定向到應用程序時顯示爲iframe。

+0

嗨,對不起。當Facebook重定向到那個URL用戶看到他們的牆。 –

+1

當用戶點擊來自他的應用程序請求的請求時,他應該被重定向到像這樣的http://apps.facebook.com/yourappname/?request_ids=xxxxxxx這樣的url,如果你已經爲你的應用程序設置了canvas頁面url ,那麼它會將該頁面作爲畫布(iframe)包含到Facebook中。 – Vijay