风扇 - 只有在的Facebook内容与asp.net C#SDK [英] Fans-only content in facebook with asp.net C# sdk

查看:150
本文介绍了风扇 - 只有在的Facebook内容与asp.net C#SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是在开发Facebook的使用C#SDK的应用程序,我想这人很喜欢我的网页只能用我的应用程序的用户。 (如 woobox

Hi i'm developing an application in facebook with c# sdk and i want that the user whom liked my page can only use my application. (Like woobox)

我发现在PHP中一些解决方案在此链接但没有关于.NET的任何来源如何我可以得到喜欢的信息ASP.NET

I found some solutions in php in this link but there isn't any source about .net how can i get the liked info in ASP.NET

我觉得在此链接但我无法找到C#的答案:\\

I find another examples in php in this link again but i can't find c# answer :\

感谢

推荐答案

当网页被Facebook的帆布应用程序中加载你得到签名的请求;你应该能够签署类似的东西要求要解析如下:

You get signed request when your web page is loaded within facebook canvas app; you should be able to parse signed request something similar to following:

if (Request.Params["signed_request"] != null)
{
    string payload = Request.Params["signed_request"].Split('.')[1];
    var encoding = new UTF8Encoding();
    var decodedJson = payload.Replace("=", string.Empty).Replace('-', '+').Replace('_', '/');
    var base64JsonArray = Convert.FromBase64String(decodedJson.PadRight(decodedJson.Length + (4 - decodedJson.Length % 4) % 4, '='));
    var json = encoding.GetString(base64JsonArray);
    var o = JObject.Parse(json);
    var lPid = Convert.ToString(o.SelectToken("page.id")).Replace("\"", "");
    var lLiked = Convert.ToString(o.SelectToken("page.liked")).Replace("\"", "");
    var lUserId= Convert.ToString(o.SelectToken("user_id")).Replace("\"", "");
}

您需要的顺序添加引用JSON库解析签署requestin C#,从下载 HTTP://json.$c$ cplex.com/

You need to add reference to json libraries in order to parse signed requestin C#, download from http://json.codeplex.com/

另外要参考,<一个href=\"http://stackoverflow.com/questions/3433252/how-to-de$c$c-oauth-2-0-for-canvas-signed-request-in-c\">How脱code的OAuth 2.0帆布signed_request在C#中?如果你worndering关于签名的请求。

Also refere to How to decode OAuth 2.0 for Canvas signed_request in C#? if you are worndering about signed request.

这篇关于风扇 - 只有在的Facebook内容与asp.net C#SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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