我有一個現有的asp.net網絡應用程序,使用Facebook來驗證用戶。我用這Facebook的工具包http://facebooktoolkit.codeplex.com/FB.Init與Facebook開發工具包異步
我的頁面有以下代碼:
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php"
type="text/javascript"></script>
<script type="text/javascript">
//Login and redirect
function onLogin() {
window.location.href = "facebookusermapping.aspx";
}
</script>
<div class="FBLogin"><fb:login-button onlogin="onLogin()"></fb:login-button></div>
<script type="text/javascript">FB.init("<%=ConfigurationManager.AppSettings["ApiKey"]%>","xd_receiver.htm");</script>
我的頁面需要花費一些時間,因爲它似乎在等待Facebook的登錄按鈕和東西加載加載,所以有人建議我做異步使用此代碼:
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'YOUR APP ID',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
};
(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);
}());
</script>
但這其中使用的工具包,我認爲是使用舊的API新的API?
當我使用我現有的代碼來檢查用戶是否通過身份驗證時,它總是返回爲false。
不需要重新編寫太多任何人都知道一種方式,我可以阻止我的頁面等待Facebook的東西加載?
謝謝...不幸的是我認爲會是這樣!我沒有意識到,舊的API將在幾個月內停止工作!我已經重寫了它! – Bex 2010-11-15 11:04:13
我除了新的Facebook C#SDK一直都很開心外,沒有什麼可以添加的。在那裏的其他圖書館有很大的改進。 – mfanto 2011-01-30 22:53:47