public string UploadUserAvatarFromSocialNetwork(int contactId, SocialNetworks socialNetwork, string userIdentity, bool uploadOnly) { if (socialNetwork != SocialNetworks.Twitter && socialNetwork != SocialNetworks.Facebook && socialNetwork != SocialNetworks.LinkedIn) throw new ArgumentException(); if (socialNetwork == SocialNetworks.Twitter) { TwitterDataProvider provider = new TwitterDataProvider(TwitterApiHelper.GetTwitterApiInfoForCurrentUser()); string imageUrl = provider.GetUrlOfUserImage(userIdentity, TwitterDataProvider.ImageSize.Original); return UploadAvatar(contactId, imageUrl, uploadOnly); } if (socialNetwork == SocialNetworks.Facebook) { FacebookDataProvider provider = new FacebookDataProvider(FacebookApiHelper.GetFacebookApiInfoForCurrentUser()); string imageUrl = provider.GetUrlOfUserImage(userIdentity, FacebookDataProvider.ImageSize.Original); return UploadAvatar(contactId, imageUrl, uploadOnly); } if (socialNetwork == SocialNetworks.LinkedIn) { LinkedInDataProvider provider = LinkedInApiHelper.GetLinkedInDataProviderForCurrentUser(); string imageUrl = provider.GetUrlOfUserImage(userIdentity); return UploadAvatar(contactId, imageUrl, uploadOnly); } return null; }
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); }
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 string UploadUserAvatarFromSocialNetwork(int contactID, SocialNetworks socialNetwork, string userIdentity, bool uploadOnly) { 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 UploadAvatar(contactID, imageUrl, uploadOnly); } if (socialNetwork == SocialNetworks.Facebook) { FacebookDataProvider provider = new FacebookDataProvider(FacebookApiHelper.GetFacebookApiInfoForCurrentUser()); string imageUrl = provider.GetUrlOfUserImage(userIdentity, FacebookDataProvider.ImageSize.Original); return UploadAvatar(contactID, imageUrl, uploadOnly); } if (socialNetwork == SocialNetworks.LinkedIn) { LinkedInDataProvider provider = LinkedInApiHelper.GetLinkedInDataProviderForCurrentUser(); string imageUrl = provider.GetUrlOfUserImage(userIdentity); return UploadAvatar(contactID, imageUrl, uploadOnly); } return null; } catch (Exception ex) { throw ProcessError(ex, "UploadUserAvatarFromSocialNetwork"); } }
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; }