我正在尝试从 SDK 的 V5.3.2 迁移到 V6。我有一个 ASP.NET 4.0 Canvas 应用程序。我注意到现在没有更多的 facebook.web.dll(我以前使用过),并找到了以下信息:
> Removal of Facebook.Web.dll and Facebook.Web.Mvc.dll Starting from v6, we are depreciating Facebook.Web.dll and Facebook.Web.Mvc.dll and will no longer be providing it. ... Starting from v6, you will have to use the Facebook Javascript SDK to get the access token and pass it to the server using secure https connection or use the Facebook OAuth Login Dialog. Decoding signed request (ParseSignedRequest/TryParseSignedRequest) has been moved to FacebookClient instead.
var fb = new FacebookClient();
dynamic signedRequest = fb.ParseSignedRequest("app_secret", Request.Params["signed_request"]);
<<<< ( http://blog.prabir.me/post/Facebook-CSharp-SDK-Glimpse-into-the-Future.aspx ) 所以这一切都很好。以前,我的代码中有这个:
protected void Page_Load(object sender, EventArgs e)
{
var auth = new CanvasAuthorizer { Permissions = new[] { "user_about_me" } };
if (auth.Authorize())
{
ShowFacebookContent();
}
}
要更改它,我现在已成功加载 Javascript SDK 并登录我的用户:
<div id="fb-root"></div>
<script type="text/javascript">
FB.init({ appId: 'xxxxxxx', cookie: true, status: true, oauth: true });
FB.getLoginStatus(function (response) {
if (response) {
alert(response.authResponse.accessToken);
}
});
</script>
我已经对此进行了测试,它成功地登录了用户。但是我如何让它做回发并调用它之前调用的服务器端方法(ShowFacebookContent)?我假设无论我做什么都必须传递 accessToken 或 SignedRequest,这样 fb.ParseSignedRequest 才能工作,并且我们可以在服务器上生成 FacebookClient。
我猜有几个人会遇到类似的情况,试图迁移出 facebook.web.dll,所以任何指导都会非常好。
最佳答案
根据您的需要传递 signed_request 或 access_token。
并且也不要通过 http 传递 access_token。使用安全的 https 连接。
关于c# - 从 Facebook C# SDK 的 V5 迁移到 V6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9363077/