public void SetEndpointsContainer()
 {
     WeatherEndpoint     = new WeatherEndpoint();
     FindEndpoint        = new FindEndpoint();
     GroupEndpoint       = new GroupEndpoint();
     NonExistingEndpoint = new NonExistingEndpoint();
 }
Example #2
0
        public ActionResult Edit(string id)
        {
            int userId      = WebSecurity.GetUserId(WebSecurity.CurrentUserName);
            var userProfile = _userContext.UserProfiles.First(x => x.UserId == userId);

            UserData userData = new UserData();

            userData.PublicKey = userProfile.PublicKey;
            userData.Timestamp = DateTime.Now;
            userData.GenerateAuthenticationHash(userProfile.PrivateKey + userProfile.PublicKey + "GET/contact/" + id + userData.Timestamp + userProfile.PrivateKey);

            ContactEndpoint c       = new ContactEndpoint();
            var             contact = c.GetContact(id, userData);

            GroupEndpoint g = new GroupEndpoint();

            userData.GenerateAuthenticationHash(userProfile.PrivateKey + userProfile.PublicKey + "GET/contact/1/9999/true" + userData.Timestamp + userProfile.PrivateKey);
            var groups       = g.GetGroups(1, 9999, userData);
            var currentGroup = groups.FirstOrDefault(gr => gr._id == contact.contact.parentId);

            ViewBag.Groups = groups;

            ViewBag.GroupName = (currentGroup == null ? "---" : currentGroup.name);

            return(View(contact));
        }
        public ActionResult Create(Group model)
        {
            int id          = WebSecurity.GetUserId(WebSecurity.CurrentUserName);
            var userProfile = _userContext.UserProfiles.First(x => x.UserId == id);

            if (string.IsNullOrWhiteSpace(userProfile.PrivateKey) || string.IsNullOrWhiteSpace(userProfile.PublicKey))
            {
                TempData["Notification"] = new Notification("Please provide access keys that have been sent you by email", Nature.warning);
                return(RedirectToAction("Account", "Settings"));
            }

            if (ModelState.IsValid)
            {
                UserData userData = new UserData();
                userData.PublicKey = userProfile.PublicKey;
                userData.Timestamp = DateTime.Now;
                userData.GenerateAuthenticationHash(userProfile.PrivateKey + userProfile.PublicKey + "POST/contact" + userData.Timestamp + userProfile.PrivateKey);

                GroupEndpoint g = new GroupEndpoint();
                model.isContactGroup = true;
                string message = g.CreateGroup(model, userData);

                TempData["Notification"] = new Notification("Group has been added" + message, Nature.success);
                Thread.Sleep(2500);
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(model));
            }
        }
            public async Task GetMember()
            {
                const int id      = 99123;
                var       members = await GroupEndpoint.GetMembers(id);

                Assert.NotNull(members);
                Assert.NotEmpty(members.List);
            }
            public async Task GetInfo()
            {
                const int id    = 99123;
                var       group = await GroupEndpoint.GetInfo(id);

                Assert.NotNull(group);
                Assert.Equal(group.Id, id);
            }
            public async Task GetGroups()
            {
                var groups = await GroupEndpoint.GetGroups("English");

                Assert.NotNull(groups);
                Assert.NotNull(groups.List);
                Assert.NotEmpty(groups.List);
            }
Example #7
0
        static void Main(string[] args)
        {
            // user end-point
            var user = new UserEndpoint(username: "", password: "");

            user.Post("Send from Facebook SDK");                        // post to logged users wall
            // Missing some stuff as like, comment, block another user, etc
            user.GetUserInfo("beciuu94", new Models.User.UserInfoOption // gather another user information
            {
                FbInfoOption = new Models.User.FacebookInfoOption
                {
                    IncludeAvatarUrl       = true,
                    IncludeFbFriends       = true,
                    IncludeFbUrl           = true,
                    IncludeUserDisplayName = true,
                    IncludeUserId          = true
                },
                IncludeAddressInfo      = true,
                IncludeBasicInfo        = true,
                IncludeContactInfo      = false,
                IncludeEduInfo          = false,
                IncludeRelationshipInfo = false,
                IncludeWorkInfo         = false
            });

            // Page end-point
            var page = new PageEndpoint(username: "", password: "");

            page.GetPageId(pageAlias: "FHNChallengingTheImpossible");             // get id from page alias
            page.GetPageAlbums(pageAlias: "FHNChallengingTheImpossible");         // get album list of a page using page alias
            page.GetPageReviewInfo(pageIdOrAlias: "FHNChallengingTheImpossible"); // get review of pages
            page.LikePage(pageIdOrAlias: "FHNChallengingTheImpossible");          // like a page
            page.GetPageAlbumImages(pageAlias: "FHNChallengingTheImpossible", albumId: "568853546917720");

            // messy stuff
            // I'm not sure we can use this method for user or group posts. Not tested yet.
            page.CommentToPageAlbumImage("https://m.facebook.com/photo.php?fbid=569190373550704&id=533880033748405", "Hi");
            page.LikePhoto(targetId: "target id is photo picture in a page."); // hmm

            // Group end-point
            var group = new GroupEndpoint(username: "", password: "");

            group.GetJoinedGroups();
            group.Post(message: "hello I'm new", groupId: "1234567");
            group.JoinGroup(groupId: "1234567");
            group.CancelJoinGroup(groupId: "1234567"); // incase your join group is pending for processing
            group.LeaveGroup(groupId: "1234567", preventReAdd: true);
            group.GetGroupInfo(groupId: "1234567");    // get group information, member list, admin, etc...

            Console.WriteLine();
        }
Example #8
0
        public ActionResult Create()
        {
            int id          = WebSecurity.GetUserId(WebSecurity.CurrentUserName);
            var userProfile = _userContext.UserProfiles.First(x => x.UserId == id);

            Contact       c = new Contact();
            GroupEndpoint g = new GroupEndpoint();

            UserData userData = new UserData();

            userData.PublicKey = userProfile.PublicKey;
            userData.Timestamp = DateTime.Now;
            userData.GenerateAuthenticationHash(userProfile.PrivateKey + userProfile.PublicKey + "GET/contact/1/9999/true" + userData.Timestamp + userProfile.PrivateKey);

            ViewBag.Groups = g.GetGroups(1, 9999, userData);

            return(View(c));
        }
        public ActionResult Edit(string id)
        {
            int userId      = WebSecurity.GetUserId(WebSecurity.CurrentUserName);
            var userProfile = _userContext.UserProfiles.First(x => x.UserId == userId);

            UserData userData = new UserData();

            userData.PublicKey = userProfile.PublicKey;
            userData.Timestamp = DateTime.Now;
            userData.GenerateAuthenticationHash(userProfile.PrivateKey + userProfile.PublicKey + "GET/contact/" + id + userData.Timestamp + userProfile.PrivateKey);

            GroupEndpoint g = new GroupEndpoint();


            var group = g.GetGroup(id, userData);

            return(View(group));
        }
        public ActionResult Edit(GroupViewModel model)
        {
            int userId      = WebSecurity.GetUserId(WebSecurity.CurrentUserName);
            var userProfile = _userContext.UserProfiles.First(x => x.UserId == userId);

            model.group.isContactGroup = false;

            UserData userData = new UserData();

            userData.PublicKey = userProfile.PublicKey;
            userData.Timestamp = DateTime.Now;
            userData.GenerateAuthenticationHash(userProfile.PrivateKey + userProfile.PublicKey + "POST/contact/" + model.group._id + userData.Timestamp + userProfile.PrivateKey);

            GroupEndpoint g       = new GroupEndpoint();
            string        message = g.UpdateGroup(model.group, userData);

            TempData["Notification"] = new Notification("Group details has been saved" + message, Nature.success);
            Thread.Sleep(2500);

            return(RedirectToAction("Index"));
        }
        public ActionResult Index(string searchQuery, string searchScope, int?pageNumber, int pageSize = 12)
        {
            int id          = WebSecurity.GetUserId(WebSecurity.CurrentUserName);
            var userProfile = _userContext.UserProfiles.First(x => x.UserId == id);

            searchScope = "all";
            if (string.IsNullOrWhiteSpace(userProfile.PrivateKey) || string.IsNullOrWhiteSpace(userProfile.PublicKey))
            {
                TempData["Notification"] = new Notification("Please provide access keys that have been sent you by email", Nature.warning);
                return(RedirectToAction("Settings", "Account"));
            }

            pageNumber = pageNumber ?? 1;

            GroupEndpoint g        = new GroupEndpoint();
            UserData      userData = new UserData();

            userData.PublicKey = userProfile.PublicKey;
            userData.Timestamp = DateTime.Now;

            List <Group> result;

            if (string.IsNullOrWhiteSpace(searchQuery) || searchScope == null)
            {
                userData.GenerateAuthenticationHash(userProfile.PrivateKey + userProfile.PublicKey + "GET/contact/" + pageNumber.Value + "/" + pageSize + "/true" + userData.Timestamp + userProfile.PrivateKey);
                result = g.GetGroups(pageNumber.Value, pageSize, userData);
            }
            else
            {
                userData.GenerateAuthenticationHash(userProfile.PrivateKey + userProfile.PublicKey + "GET/contact/" + searchScope + "/" + searchQuery + "/" + pageNumber.Value + "/" + pageSize + "/true" + userData.Timestamp + userProfile.PrivateKey);
                result = g.GetFilteredGroups(searchScope, searchQuery, pageNumber.Value, pageSize, userData);
            }

            ViewBag.SearchQuery = searchQuery;
            return(View(result));
        }
            public async Task GetListByUserToGroup()
            {
                var list = await GroupEndpoint.GetListByUser(690273);

                Assert.NotNull(list);
            }