从迁移到V5 Facebook的C#SDK的V6 [英] Migrating from V5 to V6 of the Facebook C# SDK

查看:152
本文介绍了从迁移到V5 Facebook的C#SDK的V6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从迁移到V5.3.2 SDK的V6发动机。我有一个ASP.NET 4.0应用程序画布。我注意到,现在有没有更多的Facebook.Web.dll中(这是我以前使用),并发现该信息:






> Facebook.Web.dll中和Facebook.Web.Mvc.dll

脱除V6,我们正在贬值Facebook.Web.dll中和Facebook.Web启动.Mvc.dll和将不再提供它。

从V6开始,你将不得不使用Facebook的Javascript SDK来获得访问令牌,并使用安全的HTTPS连接,将它传递给服务器,或者使用Facebook的OAuth登录对话框。
解码签名的请求(ParseSignedRequest / TryParseSignedRequest)已经移动到FacebookClient代替






  VAR FB =新FacebookClient(); 
动态signedRequest = fb.ParseSignedRequest(app_secret,Request.Params [signed_request]);



<<<<
的http://博客。 prabir.me/post/Facebook-CSharp-SDK-Glimpse-into-the-Future.aspx
所以,这一切都很好。在此之前,我有这个后面我的代码:

 保护无效的Page_Load(对象发件人,EventArgs五)
{

变种AUTH =新CanvasAuthorizer {权限=新[] {user_about_me}};

如果(auth.Authorize())
{
ShowFacebookContent();
}
}

要改变它,我现在得到的JavaScript SDK成功加载和我的用户登录:

 < DIV ID =FB-根>< / DIV> 

<脚本类型=文/ JavaScript的>
FB.init({APPID:XXXXXXX,饼干:真,状态:真的,OAuth的:真正});

FB.getLoginStatus(功能(响应){
如果(响应){
警报(response.authResponse.accessToken);
}
}) ;

< / SCRIPT>



我测试过这一点,它成功登录用户。但我怎么再让它做回发,并调用服务器端的方法,它是(ShowFacebookContent)前打电话?我想,无论我将不得不通过的accessToken或SignedRequest使fb.ParseSignedRequest将工作和服务器上,我们可以生成FacebookClient。



我猜测那几个人会在类似的情况,试图迁移过Facebook.Web.dll中,所以任何指导将是真正伟大。


解决方案

根据您的需要通过其中的signed_request或的access_token。



和还没有通过在HTTP上的access_token。使用安全的 HTTPS 连接。


I'm trying to migrate from V5.3.2 to V6 of the SDK. I've got an ASP.NET 4.0 Canvas application. I noticed that now there's no more facebook.web.dll (which I previously used), and found this info:

> 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) So that's all well and good. Previously, I had this in my code behind:

protected void Page_Load(object sender, EventArgs e)
{

    var auth = new CanvasAuthorizer { Permissions = new[] { "user_about_me" } };

    if (auth.Authorize())
    {
        ShowFacebookContent();
    }
}

To change it, I've now got the Javascript SDK successfully loading and logging in my user:

    <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>

I've tested this and it successfully logs in the user. But how do I then get it to do a postback and call the server side method that it was calling before (ShowFacebookContent)? I assume that whatever I do will have to pass the accessToken or the SignedRequest so that fb.ParseSignedRequest will work and on the server we can generate a FacebookClient.

I'm guessing that several people will be in a similar situation, trying to migrate off of facebook.web.dll, so any guidance would be really great.

解决方案

Depending on your need pass either the signed_request or the access_token.

And also don't pass the access_token over http. Use secure https connection.

这篇关于从迁移到V5 Facebook的C#SDK的V6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆