我一直在嘗試像這樣讓它工作。我非常有信心,我的Facebook應用安裝正確,並且使用了正確的appId和appSecret。當我調試的Login.aspx將斷點設置在Facebook的C#SDK永遠不會得到IsAthorized()返回true
if (response.session)
我看到它與正常的access_token填寫。但是當它碰到後面的代碼時
if (auth.IsAuthorized())
總是錯誤的!以下是aspx頁面上的代碼,僅僅是示例。
<h2>Log In </h2>
<p>
<fb:login-button autologoutlink="true" perms="email,user_birthday,offline_access,status_update,publish_stream"></fb:login-button>
</p>
<div id="fb-root">
</div>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
FB.init({ appId: '<%: Facebook.FacebookContext.Current.AppId %>', status: true, cookie: true, xfbml: true });
FB.Event.subscribe('auth.sessionChange', function (response) {
if (response.session) {
// A user has logged in, and a new cookie has been saved
window.location.reload();
} else {
// The user has logged out, and the cookie has been cleared
//src="http://connect.facebook.net/en_US/all.js"
}
});
</script>
我甚至在登錄頁面
public FacebookSession CurrentSession
{
get { return (new CanvasAuthorizer()).Session; }
}
if (CurrentSession != null)
{
Facebook.FacebookClient fbApp = new FacebookClient(CurrentSession.AccessToken);
dynamic result = fbApp.Get("/me");
}
的代碼隱藏使用這種嘗試和CurrentSession總是空爲好。
我一直在絞死我的大腦和谷歌就像這樣。而且,我覺得我已經正確設置了FB應用程序。哦,我正在使用最新的下載,5.0.03測試版。謝謝!
我不確定這是否有任何區別,但這是對我有用的東西:我在服務器端使用「授權者」而不是「CanvasAuthorizer」和。 – HOCA 2011-03-08 23:02:53