예제 #1
0
        public ActionResult About()
        {
            FacebookWebAuthorizer fwa = new FacebookWebAuthorizer(new PraLoupFacebookApplication(), HttpContext);
            fwa.Permissions = new string[]{"publish_stream"};
            fwa.ReturnUrlPath = HttpContext.Request.Url.ToString();
            if (fwa.Authorize())
            {
                var oAuth = new OAuthHandler();

                //Get the access token and secret.
                oAuth.Token = FacebookWebContext.Current.AccessToken;
                Friends f = new Friends(oAuth);
                FriendsLists fl = new FriendsLists(oAuth);
            }

            return View();
        }
예제 #2
0
        public ActionResult Login()
        {
            if (!FacebookWebContext.Current.IsAuthenticated())
            {
                return View();
            }
            else
            {
                try
                {
                    Register();
                }
                catch (Exception)
                {
                    return View();
                }
                FacebookWebAuthorizer fwa = new FacebookWebAuthorizer(new PraLoupFacebookApplication(), HttpContext);
                fwa.Permissions = new string[] { "publish_stream", "user_about_me", "read_friendlists","user_photos","friends_photos" };
                fwa.ReturnUrlPath = returnUrl;
                fwa.CancelUrlPath = returnUrl;
                if (fwa.Authorize())
                {
                    string url = null;
                    if (FacebookWebContext.Current.HttpContext.Request.UrlReferrer != null)
                    {
                        url = FacebookWebContext.Current.HttpContext.Request.UrlReferrer.ToString();
                    }

                    if (string.IsNullOrEmpty(url))
                    {
                        return RedirectToAction("Create", "Promotion", new { area = "Business" });
                    }
                    else
                    {
                        return Redirect(url);
                    }
                }
                return View();
            }
        }