My question is very similar this but I guess I need to take it one step further.
Facebook says "The data is passed to your application as a signed request. The signed_request parameter is a simple way to make sure that the data you're receiving is the actual data sent by Facebook."
After a user has logged into my asp c# MVC site and clicked "Register", the redirect-url is http://site/account/register. At that point (the post to the account/register control), I would like to gather the user's information using the signed request so that I can register them with my site locally. I cannot figure out how to access the data facebook makes available.
$data = json_decode(base64_url_decode($payload), true);
What is the equivalent in C#? What type of variable/data is facebook passing in the post? And how do I access "$payload"?
[HttpPost]
public ActionResult RegisterFacebook(RegisterFacebookModel model)
{
Facebook.FacebookSignedRequest sr = Facebook.FacebookSignedRequest.Parse("secret", model.signed_request);
return View(model);
}
Based on your comment, it looks like you're still looking for the response that FB is sending. I believe it it contained in the Form collection in the HttpContext Request object. So from the page you specify as the redirect, you should be able to pull it from:
HttpContext.Current.Request.Form("signed_request")
Hope that helps shed some light. I'm still learning as I go so this may not be the best solution.
thanks, Jason
Here's how to do it using Facebook SDK
Here is the code we used in the Facebook C# SDK. You don't need to do this manually if you use our sdk, but if you need to do it yourself here it is:
You can find the full source code here: http://facebooksdk.codeplex.com/SourceControl/changeset/view/f8109846cba5#Source%2fFacebook%2fFacebookApp.cs