private List <SocialMediaImageDescription> GetTwitterImageDescriptionList(Contact contact, Tenant tenant) { CoreContext.TenantManager.SetCurrentTenant(tenant); var images = new List <SocialMediaImageDescription>(); var twitterAccounts = Global.DaoFactory.GetContactInfoDao().GetListData(contact.ID, ContactInfoType.Twitter); if (twitterAccounts.Count == 0) { return(images); } var provider = new TwitterDataProvider(TwitterApiHelper.GetTwitterApiInfoForCurrentUser()); images.AddRange(from twitterAccount in twitterAccounts let imageUrl = provider.GetUrlOfUserImage(twitterAccount, TwitterDataProvider.ImageSize.Small) where imageUrl != null select new SocialMediaImageDescription { Identity = twitterAccount, ImageUrl = imageUrl, SocialNetwork = SocialNetworks.Twitter }); return(images); }
private List <SocialMediaImageDescription> GetTwitterImageDescriptionList(List <String> twitterAccounts, Tenant tenant) { var images = new List <SocialMediaImageDescription>(); if (twitterAccounts.Count == 0) { return(images); } try { CoreContext.TenantManager.SetCurrentTenant(tenant); var provider = new TwitterDataProvider(TwitterApiHelper.GetTwitterApiInfoForCurrentUser()); twitterAccounts = twitterAccounts.Distinct().ToList(); images.AddRange(from twitterAccount in twitterAccounts let imageUrl = provider.GetUrlOfUserImage(twitterAccount, TwitterDataProvider.ImageSize.Small) where imageUrl != null select new SocialMediaImageDescription { Identity = twitterAccount, ImageUrl = imageUrl, SocialNetwork = SocialNetworks.Twitter }); } catch (Exception ex) { _logger.Error(ex); } return(images); }
private void StartFirstThread() { var apiInfo = new TwitterApiInfo { AccessToken = "313315355-DT9HzoZKyLC4WbfKblVh5KAMyE0IGvtx5XFDtUx5", AccessTokenSecret = "7BhEPtC9RaQK0VIHmrugaimXXoOYjxxVhZGpcxw1w", ConsumerKey = "hYd5c8gYxhy3T2Nvj8wLA", ConsumerSecret = "KZGPvAN6kgioWlf0zrGYOzKevLatexuuuJlIhJQg" }; var provider = new TwitterDataProvider(apiInfo); try { var result = provider.GetUrlOfUserImage("kamorin_roman", TwitterDataProvider.ImageSize.Small); var messages = provider.GetUserHomeTimeLine(10); } catch (Exception) { } Console.WriteLine("First thread complete"); }
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"); } }