我一直在尝试像这样让它工作。我非常有信心,我的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