示例#1
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);
        }
示例#2
0
        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 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);
 }
示例#4
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");
            }
        }