德code签名的请求没有认证 [英] Decode Signed Request Without Authentication
问题描述
我们是否能够使用Facebook C#SDK脱code在 signed_request 传递给Facebook标签页面的参数,不使用身份验证?基本上,我正在寻找一种方式来解除code和解析页JSON对象的signed_request包含的内容。
Are we able to use the Facebook C# SDK to decode the signed_request parameter that is passed to the Facebook Tab page, without using Authentication? Basically, I am looking for a way to decode and parse the page JSON object that the signed_request contains.
我要寻找在 .NET C# equivelent在这个PHP示例完成相同类型的德$ C $的C:的无缝的方式来检查,如果用户喜欢页面
I am looking for the .NET C# equivelent to accomplishing the same type of decode in this PHP example: Seamless way to check if user likes page
推荐答案
我只是粘贴相同的答案我已经回答了在另一篇文章。
I am just pasting same answer I have answered in another post.
<一个href=\"http://stackoverflow.com/questions/6595259/fans-only-content-in-facebook-with-asp-net-c-sharp-sdk\">Fans-only在Facebook的内容与asp.net C#SDK
你当你的web页面的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.
这篇关于德code签名的请求没有认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!