コード例 #1
0
        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;
        }
コード例 #2
0
ファイル: FacebookTest.cs プロジェクト: ridhouan/teamlab.v6.5
 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);
 }
コード例 #3
0
        public List<FacebookUserInfo> FindFacebookProfiles(string searchText, bool isUser)
        {
            try
            {
                FacebookApiInfo apiInfo = FacebookApiHelper.GetFacebookApiInfoForCurrentUser();
                if (apiInfo == null)
                    throw new SocialMediaAccountNotFound(SocialMediaResource.SocialMediaAccountNotFoundFacebook);

                FacebookDataProvider facebookProvider = new FacebookDataProvider(apiInfo);


                return facebookProvider.FindPages(searchText, isUser);
            }
            catch (Exception ex)
            {
                throw new SocialMediaUI().ProcessError(ex, "ASC.Api.CRM.CRMApi.FindFacebookProfiles");
            }
        }
コード例 #4
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;
        }
コード例 #5
0
        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");
            }
        }
コード例 #6
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");
            }
        }
コード例 #7
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");
            }
        }
コード例 #8
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");
            }
        }
コード例 #9
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;
 }
コード例 #10
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;
        }