2010-03-29 93 views
0

我有iframe應用程序的嚴重問題。我需要使用許多外部JS庫和其他動態stuuf,因此FMBL應用程序無法完成。當我調用require_login()時,當應用程序尚未安裝時,我得到了應用程序安裝對話框,這沒關係。但是,然後在授權應用程序進入無盡的重定向循環,如auth_token,安裝等參數。昨天我設法解決了這個問題,但今天它又被打破了...... FB發生了什麼事情?這讓我瘋狂找到一種溶劑,在網上發現的任何一種都沒有效果。Facebook的require_login()在iFrame應用程序

到目前爲止,我嘗試:

http://abhirama.wordpress.com/2010/03/07/facebook-iframe-xfbml-app/(!2010年3月7日) http://forum.developers.facebook.com/viewtopic.php?pid=156092 http://www.keywordintellect.com/facebook-development/how-to-set-up-a-facebook-iframe-application-in-php-in-5-minutes/

http://www.markdeepwell.com/2010/02/validating-a-facebook-session-within-an-iframe/ http://forum.developers.facebook.com/viewtopic.php?pid=210449 http://www.ajaxlines.com/ajax/stuff/article/facebook_fbml_rendering_in_iframe_application.php http://www.aratide.com/php/solving-the-break-out-issue-in-iframe-facebook-applications/

無上述工作......根據這些和一些FB文檔: http://wiki.developers.facebook.com/index.php/FB_RequireFeatures http://wiki.developers.facebook.com/index.php/Cross_Domain_Communication_Channel

我的示例測試文件看起來如下:

<?php 
//Link in library. 
require_once '../application/vendor/Facebook/facebook.php'; 

//Authentication Keys 
$appapikey = 'XXXX'; 
$appsecret = 'XXXX'; 

//Construct the class 
$facebook = new Facebook($appapikey, $appsecret); 

//Require login 
$user_id = $facebook->require_login(); 

?> 

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> 
<head> 
    <title></title> 
</head> 
<body> 
    <script src="http://static.ak.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script> 
    This is you: <fb:name uid="<?php echo $user_id?>"></fb:name> 
    <?php var_dump($facebook->$this->facebook->api_client->friends_get())?> 
    <script type="text/javascript"> 
FB_RequireFeatures(["XFBML"], function(){ 
    FB.Facebook.init("<?=$appapikey?>", "xd_receiver.html"); 
}); 
    </script> 
</body> 
</html> 

和跨域文件xd_receiver.html是:

<!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" > 
    <head> 
    <title>cross-domain receiver page</title> 
    </head> 
    <body> 
    <script src="http://static.ak.facebook.com/js/api_lib/v0.4/XdCommReceiver.js" type="text/javascript"></script> 
    </body> 
</html> 

我如何得到它的工作?

我正在使用Kohana框架來做到這一點,並已在facebook php庫中用url :: redirect()替換了header('Location')。

回答

0

Facebook限制了許多HTML標籤的使用。看起來你在代碼中使用了一些受限制的標籤。你有沒有嘗試刪除這些?

如果你想使用這些標籤(<body>用於例如)使它成爲一個iframe的應用程序而不是FBML ...

+0

這是一個iframe應用程序。我嘗試在iframe中調用require_login,並將我的服務器上的Facebook外部重定向到應用程序,並以URI中auth_token變量的無限循環結束。我也嘗試了FBML應用程序,並使用將iframe放入畫布中,但流程相同。 – 2010-04-04 10:08:28

1

很多你看教程都非常出過期。 Facebook API和隨附的SDK變化相當迅速,儘管這並不意味着以「舊」方式做事情是不可能的,但這些方式更可能被破壞,棄用,刪除或記錄不足。

爲了更好地支撐嘗試升級到最新的PHP SDK:https://github.com/facebook/php-sdk/

然後你就可以用這個例子作爲基礎對你正在試圖做什麼: ​​

它提出一個用戶登錄鏈接,但如果你在哪裏,你要強迫登錄背景下,只顯示已登錄的用戶(模仿舊require_login),你可以替換的內容:

// Login or logout url will be needed depending on current user state. 
if ($user) { 
    $logoutUrl = $facebook->getLogoutUrl(); 
} else { 
    $loginUrl = $facebook->getLoginUrl(); 
} 

機智h:

// Get logout URL, or redirect user to login URL 
if ($user) { 
    $logoutUrl = $facebook->getLogoutUrl(); 
} else { 
    header('Location: ' . $facebook->getLoginUrl()) ; 
} 
相關問題