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); }
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"); } }
public ProviderBase() { _commonDataProvider = new CommonDataProvider(); _facebookDataProvider = new FacebookDataProvider(); _boostMeDataProvider = new BoostMeDataProvider(); _adsDataProvider = new AdsDataProvider(); }
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"); } }
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); }
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 }); }
public FacebookSection() { _dataProvider = new FacebookDataProvider(new FacebookOAuthTokens { AppId = "1298151286893535", AppSecret = "af1a1070b3fe973af4c65ea8424c9636" }); }
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()); }
private void InitializeDataProvider() { facebookDataProvider = new FacebookDataProvider(new FacebookOAuthTokens { AppId = AppId, AppSecret = AppSecret }); rawDataProvider = new FacebookDataProvider(new FacebookOAuthTokens { AppId = AppId, AppSecret = AppSecret }); }
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)); }
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")); }
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(); }
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")); }
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); }
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 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); } }
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")); }
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")); }
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); } }
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)); }
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); }
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; } }
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 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"); } }
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"); } }
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)); }
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)); }
public async Task TestNullConfig() { var dataProvider = new FacebookDataProvider(OAuthKeys.FacebookValidKeys); await ExceptionsAssert.ThrowsAsync <ConfigNullException>(async() => await dataProvider.LoadDataAsync(null)); }
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); }