Facebook.FacebookClient.ParseSignedRequest C# (CSharp) Method

ParseSignedRequest() public method

Parse the facebook signed_request.
Throws if appSecret or signedRequestValue is null or empty. If the signedRequestValue is an invalid signed_request.
public ParseSignedRequest ( string signedRequestValue ) : object
signedRequestValue string The signed_request value.
return object
        public virtual object ParseSignedRequest(string signedRequestValue)
        {
            return ParseSignedRequest(AppSecret, signedRequestValue);
        }

Same methods

FacebookClient::ParseSignedRequest ( string appSecret, string signedRequestValue ) : object

Usage Example

        public void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (!string.IsNullOrEmpty(filterContext.HttpContext.Request[_signedKey]))
            {
                var client = new FacebookClient();
                client.AppId = GetAppId();
                client.AppSecret = GetSecret();
                dynamic obj = client.ParseSignedRequest(filterContext.HttpContext.Request[_signedKey]);

                if (obj.page != null)
                {
                    bool isLiked = false;
                    isLiked = obj.page.liked;
                    if (!isLiked) return;
                }
            }

            if (string.IsNullOrEmpty(filterContext.HttpContext.Request[_statusKey]))
            {
                var resp = Resources.Filters.FacebookAuthorise;
                resp = resp.Replace(new Dictionary<string, string>()
                {
                    { "{{appId}}", this.GetAppId() },
                    { "{{permissions}}", GetPermissions() },
                    { "{{url}}", filterContext.HttpContext.Request.Url.ToString()}
                });
                filterContext.HttpContext.Response.Write(resp);
                filterContext.Result = new EmptyResult();
                return;
            }
            else if (filterContext.HttpContext.Request[_statusKey].Equals("popup-blocked"))
            {
                return;
            }
            else if (!filterContext.HttpContext.Request[_statusKey].Equals("connected"))
            {
                if (!string.IsNullOrEmpty(this.ErrorPageAction))
                {
                    var route = new RouteValueDictionary()
                        {
                            { "action", this.ErrorPageAction}
                        };
                    if (!string.IsNullOrEmpty(this.ErrorPageController))
                    {
                        route.Add("controller", this.ErrorPageController);
                    }

                    filterContext.Result = new RedirectToRouteResult(route);
                }
                else if (!string.IsNullOrEmpty(this.ErrorPageUrl))
                {
                    filterContext.HttpContext.Response.Redirect(this.ErrorPageUrl);
                }
            }
        }
All Usage Examples Of Facebook.FacebookClient::ParseSignedRequest