예제 #1
0
        public RedirectToRouteResult FacebookCallBack(string userSecret, string code)
        {
            var token = FB.GetAccessToken(userSecret, code);

            FB.GetAccountInfo("", token); //magic


            if (!_userService.IsUserExist(FB.Email))
            {
                var newUser = new UserModel
                {
                    FirstName = FB.FirstName,
                    LastName  = FB.LastName,
                    Email     = FB.Email,
                    AuthInfos = new Collection <AuthInfoModel>
                    {
                        new AuthInfoModel()
                        {
                            AuthProvider      = AuthInfoModel.ProviderType.Facebook.ToString(),
                            AuthProviderToken = token
                        }
                    }
                };
                // TODO
//                _userService.CreateUser(newUser, AuthInfoModel.ProviderType.Facebook);
            }

            Session["AccessToken"] = token;
            FormsAuthentication.SetAuthCookie(FB.Email, false);

            //var fb = new FB();
            // fb.CreateAlbum("test", "my test album", token);
            var photoCollection = new string[]
            {
                "e:\\rabbit.jpg",
                "e:\\rabbit1.jpg",
                "e:\\rabbit2.jpg",
                "e:\\rabbit3.jpg",
                "e:\\rabbit4.jpg",
                "e:\\rabbit5.jpg",
                "e:\\rabbit6.jpg",
                "e:\\rabbit7.jpg"
            };

            FB.AddPhotosToAlbum(photoCollection, "Bingally", token);
            var albumList = FB.GetListOfAlbums(token);

            return(RedirectToRoute("PublicFlow"));
        }