private List <SocialMediaImageDescription> GetFacebookImageDescriptionList(List <String> facebookAccounts, Tenant tenant)
        {
            var images = new List <SocialMediaImageDescription>();

            if (facebookAccounts.Count == 0)
            {
                return(images);
            }

            try
            {
                CoreContext.TenantManager.SetCurrentTenant(tenant);

                var provider = new FacebookDataProvider(FacebookApiHelper.GetFacebookApiInfoForCurrentUser());

                facebookAccounts = facebookAccounts.Distinct().ToList();
                images.AddRange(from facebookAccount in facebookAccounts
                                let imageUrl = provider.GetUrlOfUserImage(facebookAccount, FacebookDataProvider.ImageSize.Small)
                                               where imageUrl != null
                                               select new SocialMediaImageDescription
                {
                    Identity      = facebookAccount,
                    ImageUrl      = imageUrl,
                    SocialNetwork = SocialNetworks.Facebook
                });
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }

            return(images);
        }
Exemple #2
0
        public string FindFacebookProfiles(string searchText)
        {
            try
            {
                //Process authorization
                if (!ProcessAuthorization(HttpContext.Current))
                {
                    AccessDenied(HttpContext.Current);
                    return(null);
                }

                FacebookApiInfo apiInfo = FacebookApiHelper.GetFacebookApiInfoForCurrentUser();

                if (apiInfo == null)
                {
                    throw new SocialMediaAccountNotFound(SocialMediaResource.SocialMediaAccountNotFoundFacebook);
                }

                FacebookDataProvider facebookProvider = new FacebookDataProvider(apiInfo);

                List <FacebookUserInfo> users = facebookProvider.FindUsers(searchText);
                string result = JsonConvert.SerializeObject(users);
                return(result);
            }
            catch (Exception ex)
            {
                throw ProcessError(ex, "FindTwitterProfiles");
            }
        }
Exemple #3
0
 public ProviderBase()
 {
     _commonDataProvider   = new CommonDataProvider();
     _facebookDataProvider = new FacebookDataProvider();
     _boostMeDataProvider  = new BoostMeDataProvider();
     _adsDataProvider      = new AdsDataProvider();
 }
Exemple #4
0
        public string ShowFacebookUserRelationWindow(string userID)
        {
            try
            {
                //Process authorization
                if (!ProcessAuthorization(HttpContext.Current))
                {
                    AccessDenied(HttpContext.Current);
                    return(null);
                }

                FacebookApiInfo apiInfo = FacebookApiHelper.GetFacebookApiInfoForCurrentUser();

                if (apiInfo == null)
                {
                    throw new SocialMediaAccountNotFound(SocialMediaResource.SocialMediaAccountNotFoundFacebook);
                }

                FacebookDataProvider provider = new FacebookDataProvider(apiInfo);

                FacebookUserInfo user = provider.LoadUserInfo(userID);
                return(GetFacebookUserInfoPage(user));
            }
            catch (Exception ex)
            {
                throw ProcessError(ex, "ShowTwitterUserRelationWindow");
            }
        }
Exemple #5
0
        private List <SocialMediaImageDescription> GetFacebookImageDescriptionList(Contact contact, Tenant tenant)
        {
            CoreContext.TenantManager.SetCurrentTenant(tenant);

            var images = new List <SocialMediaImageDescription>();

            var facebookAccounts = Global.DaoFactory.GetContactInfoDao().GetListData(contact.ID, ContactInfoType.Facebook);

            if (facebookAccounts.Count == 0)
            {
                return(images);
            }

            var provider = new FacebookDataProvider(FacebookApiHelper.GetFacebookApiInfoForCurrentUser());

            images.AddRange(from facebookAccount in facebookAccounts
                            let imageUrl = provider.GetUrlOfUserImage(facebookAccount, FacebookDataProvider.ImageSize.Small)
                                           where imageUrl != null
                                           select new SocialMediaImageDescription
            {
                Identity      = facebookAccount,
                ImageUrl      = imageUrl,
                SocialNetwork = SocialNetworks.Facebook
            });

            return(images);
        }
Exemple #6
0
        public async void GetItems()
        {
            string appId              = "248058472262288";
            string appSecret          = "d74d68d717ff1a0c45dc3fbad0899d26";
            string FacebookQueryParam = "625038207649339";
            int    MaxRecordsParam    = 20;

            Items.Clear();

            _facebookDataProvider = new FacebookDataProvider(new FacebookOAuthTokens {
                AppId = appId, AppSecret = appSecret
            });
            var config = new FacebookDataConfig
            {
                UserId = FacebookQueryParam
            };

            var items = await _facebookDataProvider.LoadDataAsync(config, MaxRecordsParam);

            foreach (var item in items)
            {
                if (item.ImageUrl == null || item.ImageUrl == "")
                {
                    item.ImageUrl = "https://eclass.aueb.gr/courses/theme_data/9/eclass_aueb_logo.png";
                }
                Items.Add(item);
            }
            pring.IsActive    = false;
            pring.Visibility  = Visibility.Collapsed;
            FeedFb.Visibility = Visibility.Visible;
        }
 public Section1Section()
 {
     _dataProvider = new FacebookDataProvider(new FacebookOAuthTokens
     {
         AppId     = "1158179577528273",
         AppSecret = Vault.Facebook
     });
 }
Exemple #8
0
 public FacebookSection()
 {
     _dataProvider = new FacebookDataProvider(new FacebookOAuthTokens
     {
         AppId     = "1298151286893535",
         AppSecret = "af1a1070b3fe973af4c65ea8424c9636"
     });
 }
Exemple #9
0
 public FacebookSection()
 {
     _dataProvider = new FacebookDataProvider(new FacebookOAuthTokens
     {
         AppId     = "1823451441248936",
         AppSecret = "7317e15ecf605bfa70d54bdd90457c6e"
     });
 }
 public void GetUrlOfUserImageTest()
 {
     var ai = new FacebookApiInfo {
         AccessToken = "186245251433148|5fecd56abddd9eb63b506530.1-100002072952328|akD66RBlkeedQmhy50T9V_XCTYs"
     };
     var provider = new FacebookDataProvider(ai);
     var url      = provider.GetUrlOfUserImage("kamorin.roman", FacebookDataProvider.ImageSize.Original);
 }
 public async Task LoadMoreDataInvalidOperationFacebook()
 {
     var config = new FacebookDataConfig
     {
         UserId = "8195378771",
     };
     var dataProvider = new FacebookDataProvider(OAuthKeys.FacebookValidKeys);
     InvalidOperationException exception = await ExceptionsAssert.ThrowsAsync <InvalidOperationException>(async() => await dataProvider.LoadMoreDataAsync());
 }
Exemple #12
0
 private void InitializeDataProvider()
 {
     facebookDataProvider = new FacebookDataProvider(new FacebookOAuthTokens {
         AppId = AppId, AppSecret = AppSecret
     });
     rawDataProvider = new FacebookDataProvider(new FacebookOAuthTokens {
         AppId = AppId, AppSecret = AppSecret
     });
 }
Exemple #13
0
        public async Task TestRevokedOAuth()
        {
            var config = new FacebookDataConfig
            {
                UserId = "8195378771",
            };

            var dataProvider = new FacebookDataProvider(OAuthKeys.FacebookRevokedKeys);

            await ExceptionsAssert.ThrowsAsync <OAuthKeysRevokedException>(async() => await dataProvider.LoadDataAsync(config));
        }
        public void Execute(IJobExecutionContext context)
        {
            FacebookDataProvider provider = new FacebookDataProvider();
            Repository           repo     = new Repository();

            foreach (var post in provider.FetchDataFromFacebook())
            {
                Logger.Info("Facebook postId added/updated: " + post.ExternalKey);
                repo.AddOrUpdate(post);
            }
        }
        public async Task TestRevokedOAuth()
        {
            var config = new FacebookDataConfig
            {
                UserId = "8195378771",
            };

            var dataProvider = new FacebookDataProvider(OAuthKeys.FacebookRevokedKeys);

            await ExceptionsAssert.ThrowsAsync<OAuthKeysRevokedException>(async () => await dataProvider.LoadDataAsync(config));
        }
Exemple #16
0
        public async Task TestNullOAuth()
        {
            var config = new FacebookDataConfig
            {
                UserId = "8195378771",
            };

            var dataProvider = new FacebookDataProvider(null);

            await ExceptionsAssert.ThrowsAsync <ConfigParameterNullException>(async() => await dataProvider.LoadDataAsync(config));
        }
        public async Task LoadFacebook()
        {
            var config = new FacebookDataConfig
            {
                UserId = "8195378771",
            };
            var dataProvider = new FacebookDataProvider(OAuthKeys.FacebookValidKeys);
            IEnumerable<FacebookSchema> result = await dataProvider.LoadDataAsync(config);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Any());
        }
        public async Task TestNullUserId()
        {
            var config = new FacebookDataConfig
            {
                UserId = null,
            };

            var dataProvider = new FacebookDataProvider(OAuthKeys.FacebookValidKeys);

            ConfigParameterNullException exception = await ExceptionsAssert.ThrowsAsync<ConfigParameterNullException>(async () => await dataProvider.LoadDataAsync(config));
            Assert.IsTrue(exception.Message.Contains("UserId"));
        }
Exemple #19
0
 public ProviderBase()
 {
     _localizationDataProvider = new LocalizationDataProvider();
     _appsDataProvider = new AppsDataProvider();
     _facebookDataProvider = new FacebookDataProvider();
     _userDataProvider = new UserDataProvider();
     _userFavoritesDataProvider = new UserFavoritesDataProvider();
     _userMessagesDataProvider = new UserMessagesDataProvider();
     _userVisitsDataProvider = new UserVisitsDataProvider();
     _userLikesDataProvider = new UserLikesDataProvider();
     _geoIpDataProvider = new GeoIpDataProvider();
 }
Exemple #20
0
        public async Task TestMaxRecords_Min()
        {
            int maxRecords = 1;
            var config     = new FacebookDataConfig
            {
                UserId = "8195378771",
            };
            var dataProvider = new FacebookDataProvider(OAuthKeys.FacebookValidKeys);
            IEnumerable <FacebookSchema> result = await dataProvider.LoadDataAsync(config, maxRecords);

            Assert.AreEqual(maxRecords, result.Count());
        }
        public async Task TestEmptyOAuth()
        {
            var config = new FacebookDataConfig
            {
                UserId = "8195378771",
            };

            var dataProvider = new FacebookDataProvider(new FacebookOAuthTokens());

            OAuthKeysNotPresentException exception = await ExceptionsAssert.ThrowsAsync<OAuthKeysNotPresentException>(async () => await dataProvider.LoadDataAsync(config));
            Assert.IsTrue(exception.Message.Contains("AppId"));
        }
Exemple #22
0
        public async Task TestMaxRecords()
        {
            int maxRecords = 70;
            var config     = new FacebookDataConfig
            {
                UserId = "150135720497",
            };
            var dataProvider = new FacebookDataProvider(OAuthKeys.FacebookValidKeys);
            IEnumerable <FacebookSchema> result = await dataProvider.LoadDataAsync(config, maxRecords);

            Assert.IsTrue(result.Count() > 25);
        }
Exemple #23
0
        public async Task LoadFacebook()
        {
            var config = new FacebookDataConfig
            {
                UserId = "8195378771",
            };
            var dataProvider = new FacebookDataProvider(OAuthKeys.FacebookValidKeys);
            IEnumerable <FacebookSchema> result = await dataProvider.LoadDataAsync(config);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Any());
        }
Exemple #24
0
        public void Execute(IJobExecutionContext context)
        {
            FacebookDataProvider provider   = new FacebookDataProvider();
            Repository           repository = new Repository();

            foreach (var post in provider.FetchPostsFromFacebook())
            {
                Logger.Info(string.Format("Facebook postId added/updated: {0}", post.ExternalKey));
                repository.PostsAddOrUpdate(post);

                UpdatePostDetails(post, provider, repository);
            }
        }
Exemple #25
0
        public async Task TestEmptyOAuth()
        {
            var config = new FacebookDataConfig
            {
                UserId = "8195378771",
            };

            var dataProvider = new FacebookDataProvider(new FacebookOAuthTokens());

            OAuthKeysNotPresentException exception = await ExceptionsAssert.ThrowsAsync <OAuthKeysNotPresentException>(async() => await dataProvider.LoadDataAsync(config));

            Assert.IsTrue(exception.Message.Contains("AppId"));
        }
Exemple #26
0
        public async Task TestNullUserId()
        {
            var config = new FacebookDataConfig
            {
                UserId = null,
            };

            var dataProvider = new FacebookDataProvider(OAuthKeys.FacebookValidKeys);

            ConfigParameterNullException exception = await ExceptionsAssert.ThrowsAsync <ConfigParameterNullException>(async() => await dataProvider.LoadDataAsync(config));

            Assert.IsTrue(exception.Message.Contains("UserId"));
        }
Exemple #27
0
        private void UpdatePostDetails(FacebookPost post, FacebookDataProvider provider, Repository repository)
        {
            var likesAndUsers = provider.GetLikesAndUsersForPostFromFacebook(post.ExternalKey);

            foreach (var like in likesAndUsers.Item1)
            {
                repository.LikesAdd(like);
            }

            foreach (var user in likesAndUsers.Item2)
            {
                repository.UsersAddOrUpdate(user);
            }
        }
Exemple #28
0
        public async Task TestInvalidOAuth()
        {
            var config = new FacebookDataConfig
            {
                UserId = "8195378771",
            };

            var tokens = new FacebookOAuthTokens
            {
                AppId     = "INVALID",
                AppSecret = "INVALID"
            };

            var dataProvider = new FacebookDataProvider(tokens);

            await ExceptionsAssert.ThrowsAsync <OAuthKeysRevokedException>(async() => await dataProvider.LoadDataAsync(config));
        }
        public async Task TestInvalidOAuth()
        {
            var config = new FacebookDataConfig
            {
                UserId = "8195378771",
            };

            var tokens = new FacebookOAuthTokens
            {
                AppId = "INVALID",
                AppSecret = "INVALID"
            };

            var dataProvider = new FacebookDataProvider(tokens);

            await ExceptionsAssert.ThrowsAsync<OAuthKeysRevokedException>(async () => await dataProvider.LoadDataAsync(config));
        }
Exemple #30
0
        private List <Message> GetUserWallFacebook()
        {
            List <Message> messageList = new List <Message>();

            try
            {
                FacebookApiInfo apiInfo = new FacebookApiInfo {
                    AccessToken = FacebookInformation.AccessToken
                };
                FacebookDataProvider facebookProvider = new FacebookDataProvider(apiInfo);
                messageList.AddRange(facebookProvider.LoadUserWall(FacebookInformation.UserID, MessageCount));
            }
            catch (Exception ex)
            {
                ThrownExceptions.Add(ex);
            }
            return(messageList);
        }
Exemple #31
0
        private async void Request()
        {
            try
            {
                IsBusy              = true;
                HasErrors           = false;
                NoItems             = false;
                DataProviderRawData = string.Empty;
                Items.Clear();

                var facebookDataProvider = new FacebookDataProvider(new FacebookOAuthTokens {
                    AppId = AppId, AppSecret = AppSecret
                });
                var config = new FacebookDataConfig
                {
                    UserId = FacebookQueryParam
                };

                var rawParser = new RawParser();
                var rawData   = await facebookDataProvider.LoadDataAsync(config, MaxRecordsParam, rawParser);

                DataProviderRawData = rawData.FirstOrDefault()?.Raw;

                var items = await facebookDataProvider.LoadDataAsync(config, MaxRecordsParam);

                NoItems = !items.Any();

                foreach (var item in items)
                {
                    Items.Add(item);
                }
            }
            catch (Exception ex)
            {
                DataProviderRawData += ex.Message;
                DataProviderRawData += ex.StackTrace;
                HasErrors            = true;
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemple #32
0
        public async void GetItems()
        {
            string appId = "YourAppId";   
            string appSecret = "YourAppSecret";
            string FacebookQueryParam = "8195378771";
            int MaxRecordsParam = 20;

            Items.Clear();

            _facebookDataProvider = new FacebookDataProvider(new FacebookOAuthTokens { AppId = appId, AppSecret = appSecret });
            var config = new FacebookDataConfig
            {
                UserId = FacebookQueryParam
            };          

            var items = await _facebookDataProvider.LoadDataAsync(config, MaxRecordsParam);         

            foreach (var item in items)
            {
                Items.Add(item);
            }
        }
Exemple #33
0
        public string FindUsers(string searchText, string socialNetwork)
        {
            try
            {
                //Process authorization
                if (!ProcessAuthorization(HttpContext.Current))
                {
                    AccessDenied(HttpContext.Current);
                    return(null);
                }
                if (socialNetwork.ToLower() == "twitter")
                {
                    TwitterDataProvider    provider = new TwitterDataProvider(TwitterApiHelper.GetTwitterApiInfoForCurrentUser());
                    List <TwitterUserInfo> users    = provider.FindUsers(searchText);
                    return(GetTwitterUserListPage(users));
                }
                if (socialNetwork.ToLower() == "facebook")
                {
                    FacebookApiInfo apiInfo = FacebookApiHelper.GetFacebookApiInfoForCurrentUser();

                    if (apiInfo == null)
                    {
                        throw new SocialMediaAccountNotFound(SocialMediaResource.SocialMediaAccountNotFoundFacebook);
                    }

                    FacebookDataProvider facebookProvider = new FacebookDataProvider(apiInfo);

                    List <FacebookUserInfo> users = facebookProvider.FindUsers(searchText);
                    return(GetFacebookUserListPage(users));
                }
                return(null);
            }
            catch (Exception ex)
            {
                throw ProcessError(ex, "FindUsers");
            }
        }
Exemple #34
0
        public string SaveUserAvatarFromSocialNetwork(int contactID, SocialNetworks socialNetwork, string userIdentity)
        {
            try
            {
                //Process authorization
                if (!ProcessAuthorization(HttpContext.Current))
                {
                    AccessDenied(HttpContext.Current);
                    return(null);
                }
                if (socialNetwork == SocialNetworks.Twitter)
                {
                    TwitterDataProvider provider = new TwitterDataProvider(TwitterApiHelper.GetTwitterApiInfoForCurrentUser());
                    string imageUrl = provider.GetUrlOfUserImage(userIdentity, TwitterDataProvider.ImageSize.Original);
                    return(SaveAvatar(contactID, imageUrl));
                }
                if (socialNetwork == SocialNetworks.Facebook)
                {
                    FacebookDataProvider provider = new FacebookDataProvider(FacebookApiHelper.GetFacebookApiInfoForCurrentUser());
                    string imageUrl = provider.GetUrlOfUserImage(userIdentity, FacebookDataProvider.ImageSize.Original);
                    return(SaveAvatar(contactID, imageUrl));
                }

                if (socialNetwork == SocialNetworks.LinkedIn)
                {
                    LinkedInDataProvider provider = LinkedInApiHelper.GetLinkedInDataProviderForCurrentUser();
                    string imageUrl = provider.GetUrlOfUserImage(userIdentity);
                    return(SaveAvatar(contactID, imageUrl));
                }
                return(null);
            }
            catch (Exception ex)
            {
                throw ProcessError(ex, "SaveUserAvatarFromSocialNetwork");
            }
        }
Exemple #35
0
        public async void GetItems()
        {
            string appId              = "YourAppId";
            string appSecret          = "YourAppSecret";
            string FacebookQueryParam = "8195378771";
            int    MaxRecordsParam    = 20;

            Items.Clear();

            _facebookDataProvider = new FacebookDataProvider(new FacebookOAuthTokens {
                AppId = appId, AppSecret = appSecret
            });
            var config = new FacebookDataConfig
            {
                UserId = FacebookQueryParam
            };

            var items = await _facebookDataProvider.LoadDataAsync(config, MaxRecordsParam);

            foreach (var item in items)
            {
                Items.Add(item);
            }
        }
 public async Task LoadMoreDataInvalidOperationFacebook()
 {
     var config = new FacebookDataConfig
     {
         UserId = "8195378771",
     };
     var dataProvider = new FacebookDataProvider(OAuthKeys.FacebookValidKeys);
     InvalidOperationException exception = await ExceptionsAssert.ThrowsAsync<InvalidOperationException>(async () => await dataProvider.LoadMoreDataAsync());
 }
        public async Task TestMaxRecords_Min()
        {
            int maxRecords = 1;
            var config = new FacebookDataConfig
            {
                UserId = "8195378771",
            };
            var dataProvider = new FacebookDataProvider(OAuthKeys.FacebookValidKeys);
            IEnumerable<FacebookSchema> result = await dataProvider.LoadDataAsync(config, maxRecords);

            Assert.AreEqual(maxRecords, result.Count());
        }
        public async Task TestNullOAuth()
        {
            var config = new FacebookDataConfig
            {
                UserId = "8195378771",
            };

            var dataProvider = new FacebookDataProvider(null);

            await ExceptionsAssert.ThrowsAsync<ConfigParameterNullException>(async () => await dataProvider.LoadDataAsync(config));
        }
Exemple #39
0
 private void InitializeDataProvider()
 {
     facebookDataProvider = new FacebookDataProvider(new FacebookOAuthTokens { AppId = AppId, AppSecret = AppSecret });
     rawDataProvider = new FacebookDataProvider(new FacebookOAuthTokens { AppId = AppId, AppSecret = AppSecret });
 }
        public async Task TestNullParser()
        {
            var dataProvider = new FacebookDataProvider(OAuthKeys.FacebookValidKeys);

            await ExceptionsAssert.ThrowsAsync<ParserNullException>(async () => await dataProvider.LoadDataAsync<FacebookSchema>(new FacebookDataConfig(), 20, null));
        }
        public async Task TestNullConfig()
        {
            var dataProvider = new FacebookDataProvider(OAuthKeys.FacebookValidKeys);

            await ExceptionsAssert.ThrowsAsync<ConfigNullException>(async () => await dataProvider.LoadDataAsync(null));
        }
Exemple #42
0
        public async Task TestNullConfig()
        {
            var dataProvider = new FacebookDataProvider(OAuthKeys.FacebookValidKeys);

            await ExceptionsAssert.ThrowsAsync <ConfigNullException>(async() => await dataProvider.LoadDataAsync(null));
        }
Exemple #43
0
        public async Task TestNullParser()
        {
            var dataProvider = new FacebookDataProvider(OAuthKeys.FacebookValidKeys);

            await ExceptionsAssert.ThrowsAsync <ParserNullException>(async() => await dataProvider.LoadDataAsync <FacebookSchema>(new FacebookDataConfig(), 20, null));
        }
        public async Task TestMaxRecords()
        {
            int maxRecords = 70;
            var config = new FacebookDataConfig
            {
                UserId = "150135720497",
            };
            var dataProvider = new FacebookDataProvider(OAuthKeys.FacebookValidKeys);
            IEnumerable<FacebookSchema> result = await dataProvider.LoadDataAsync(config, maxRecords);

            Assert.IsTrue(result.Count() > 25);
        }