当前位置: 首页>>代码示例>>C#>>正文


C# FacebookClient.ParseSignedRequest方法代码示例

本文整理汇总了C#中Facebook.FacebookClient.ParseSignedRequest方法的典型用法代码示例。如果您正苦于以下问题:C# FacebookClient.ParseSignedRequest方法的具体用法?C# FacebookClient.ParseSignedRequest怎么用?C# FacebookClient.ParseSignedRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Facebook.FacebookClient的用法示例。


在下文中一共展示了FacebookClient.ParseSignedRequest方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnActionExecuting

        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);
                }
            }
        }
开发者ID:niallduane,项目名称:Yummy,代码行数:55,代码来源:FacebookAuthoriseAttribute.cs

示例2: OnActionExecuting

        public void OnActionExecuting(ActionExecutingContext filterContext)
        {
            //Authorisation request submitted.
            if (!string.IsNullOrEmpty(filterContext.HttpContext.Request["status"])) return;

            if (string.IsNullOrEmpty(filterContext.HttpContext.Request[_signedKey]))
            {
                return;
            }
            else
            {
                bool isLiked = false;

                var client = new FacebookClient();
                client.AppId = GetAppId();
                client.AppSecret = GetSecret();
                dynamic obj = client.ParseSignedRequest(filterContext.HttpContext.Request[_signedKey]);

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

                if ((isLiked) || (null == obj.page))
                {
                    return;
                }
            }

            if (!string.IsNullOrEmpty(this.Action))
            {
                var route = new RouteValueDictionary()
                {
                    { "action", this.Action}
                };
                if (!string.IsNullOrEmpty(this.Controller))
                {
                    route.Add("controller", this.Controller);
                }

                filterContext.Result = new RedirectToRouteResult(route);
                return;
            }
            else if (!string.IsNullOrEmpty(this.Url))
            {
                filterContext.HttpContext.Response.Redirect(this.Url);
                return;
            }

            throw new Exception("Enter Like Url or Route Data for Facebook Like Attribute.");
        }
开发者ID:niallduane,项目名称:Yummy,代码行数:51,代码来源:FacebookPageLikedAttribute.cs

示例3: CorrectlyParsesSignedRequest

        public void CorrectlyParsesSignedRequest()
        {
            var fb = new FacebookClient();

            var signedRequest = (IDictionary<string, object>)fb.ParseSignedRequest(AppSecret, SignedRequest);

            Assert.IsAssignableFrom<IDictionary<string, object>>(signedRequest);
            Assert.IsType<JsonObject>(signedRequest);

            Assert.Equal("HMAC-SHA256", signedRequest["algorithm"]);
            Assert.Equal(1336845600L, signedRequest["expires"]);
            Assert.Equal(1336841938L, signedRequest["issued_at"]);
            Assert.Equal("AAAB3grfTrXwBAIYmsIDKbgepKdL6M5IK3v4pMGAi6OEKWLzX91bZBC4ZATzadiLnbK4k8CBrSbo5ZCqW5a7aZA3F5DSHMIh3WarnNVLRGTg2TWLbpJ4z", signedRequest["oauth_token"]);
        }
开发者ID:amartyamandal,项目名称:facebook-csharp-sdk,代码行数:14,代码来源:ParseSignedRequestTests.cs

示例4: OnActionExecuting

        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            // On bypass completement l'accès facebook si la conf n'est pas à true.
            if (ConfigurationManager.AppSettings["FbEnabled"] != "true")
            {
                return;
            }
            var request = filterContext.RequestContext.HttpContext.Request;

            //vérifie si l'on est bien dans Facebook
            if (request.Params["signed_request"] != null)
            {
                var fb = new FacebookClient();

                dynamic sr = fb.ParseSignedRequest(ConfigurationManager.AppSettings["FbAppSecret"], request.Params["signed_request"]);
                filterContext.HttpContext.Session["signedRequest"] = sr;
                filterContext.HttpContext.Session["SignedRequestReceived"] = true;
                if (sr.page != null)
                {
                    //page is liked or not ?
                    if (!sr.page.liked && RedirectIfPageNotLiked)
                    {
                        filterContext.Result = new RedirectResult("~/");
                    }
                }
            }
            else if (filterContext.HttpContext.Session["SignedRequestReceived"] != null)
            {
                filterContext.HttpContext.Session["SignedRequestReceived"] = false;
                return;
            }
            else
            {
                filterContext.Result = new RedirectResult(ConfigurationManager.AppSettings["FbAppRoot"]);
            }
            base.OnActionExecuting(filterContext);
        }
开发者ID:BlueInt32,项目名称:Tools,代码行数:37,代码来源:FacebookFilter.cs

示例5: GetFacebookUserData

        private dynamic GetFacebookUserData(string _signedRequest)
        {
            FacebookClient client = new FacebookClient();
            dynamic signedRequest = client.ParseSignedRequest(ConfigurationManager.AppSettings["facebook_appsecret"].ToString(), _signedRequest);

            client.AppId = ConfigurationManager.AppSettings["facebook_appid"].ToString();
            client.AppSecret = ConfigurationManager.AppSettings["facebook_appsecret"].ToString();

            if (signedRequest.ContainsKey("oauth_token"))
                client.AccessToken = (string)signedRequest["oauth_token"];
            else
                return null;

            dynamic response = client.Get("me");
            return response;
        }
开发者ID:brianhprince,项目名称:FBwithWA,代码行数:16,代码来源:RegisterController.cs

示例6: ThrowsArgumentNullExceptionIfSignedRequestIsEmpty

        public void ThrowsArgumentNullExceptionIfSignedRequestIsEmpty()
        {
            var fb = new FacebookClient();

            Assert.Throws<ArgumentNullException>(() => fb.ParseSignedRequest(AppSecret, string.Empty));
        }
开发者ID:amartyamandal,项目名称:facebook-csharp-sdk,代码行数:6,代码来源:ParseSignedRequestTests.cs

示例7: ThrowsArgumentNullExceptionIfAppSecretIsNull

        public void ThrowsArgumentNullExceptionIfAppSecretIsNull()
        {
            var fb = new FacebookClient();

            Assert.Throws<ArgumentNullException>(() => fb.ParseSignedRequest(null, SignedRequest));
        }
开发者ID:amartyamandal,项目名称:facebook-csharp-sdk,代码行数:6,代码来源:ParseSignedRequestTests.cs


注:本文中的Facebook.FacebookClient.ParseSignedRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。