Пример #1
0
        public static List <Domain.Socioboard.Models.TwitterMutualFans> twitterfans(long groupId, Model.DatabaseRepository dbr, Helper.AppSettings _appSettings)
        {
            string[] profileids = null;
            List <Domain.Socioboard.Models.TwitterMutualFans> lstTwitterUserfans = new List <Domain.Socioboard.Models.TwitterMutualFans>();
            List <Domain.Socioboard.Models.Groupprofiles>     lstGroupprofiles   = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.Twitter).ToList();

            profileids = lstGroupprofiles.Select(t => t.profileId).ToArray();
            List <Domain.Socioboard.Models.TwitterAccount> lstAccRepo = dbr.Find <Domain.Socioboard.Models.TwitterAccount>(t => profileids.Contains(t.twitterUserId) && t.isActive).ToList();
            oAuthTwitter  oaut          = null;
            Users         twtUser       = new Users();
            List <string> mutualfanlist = new List <string>();
            List <string> followersId   = new List <string>();

            foreach (Domain.Socioboard.Models.TwitterAccount itemTwt in lstAccRepo)
            {
                oaut                   = new oAuthTwitter();
                oaut.AccessToken       = itemTwt.oAuthToken;
                oaut.AccessTokenSecret = itemTwt.oAuthSecret;
                oaut.TwitterScreenName = itemTwt.twitterScreenName;
                oaut.TwitterUserId     = itemTwt.twitterUserId;
                oaut.ConsumerKey       = _appSettings.twitterConsumerKey;
                oaut.ConsumerKeySecret = _appSettings.twitterConsumerScreatKey;
                JArray jarresponse = twtUser.Get_Followers_ById(oaut, itemTwt.twitterUserId);
                JArray user_data   = JArray.Parse(jarresponse[0]["ids"].ToString());
                JArray jarrespons  = twtUser.Get_Friends_ById(oaut, itemTwt.twitterUserId);
                JArray user_data_2 = JArray.Parse(jarrespons[0]["ids"].ToString());
                foreach (var items in user_data.Intersect(user_data_2))
                {
                    mutualfanlist.Add(items.ToString());
                }
                foreach (var itemss in user_data)
                {
                    followersId.Add(itemss.ToString());
                }
                List <string> fansId = followersId.Except(mutualfanlist).ToList();
                foreach (var items in fansId)
                {
                    Domain.Socioboard.Models.TwitterMutualFans objTwitterFans = new Domain.Socioboard.Models.TwitterMutualFans();
                    JArray userprofile = twtUser.Get_Users_LookUp(oaut, items);
                    foreach (var item in userprofile)
                    {
                        objTwitterFans.screen_name = item["screen_name"].ToString();
                        objTwitterFans.name        = item["name"].ToString();
                        lstTwitterUserfans.Add(objTwitterFans);
                    }
                }
            }
            return(lstTwitterUserfans);
        }
Пример #2
0
        public static List <Domain.Socioboard.Models.TwitterMutualFans> twitterfollowerslist(string profileId, Model.DatabaseRepository dbr, Helper.AppSettings _appSettings)
        {
            string profileids = profileId;
            List <Domain.Socioboard.Models.TwitterMutualFans> lstfollowerlist = new List <Domain.Socioboard.Models.TwitterMutualFans>();
            //List<Domain.Socioboard.Models.Groupprofiles> lstGroupprofiles = dbr.Find<Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.Twitter).ToList();
            //profileids = lstGroupprofiles.Select(t => t.profileId).ToArray();
            List <Domain.Socioboard.Models.TwitterAccount> lstAccRepo = dbr.Find <Domain.Socioboard.Models.TwitterAccount>(t => profileids.Contains(t.twitterUserId) && t.isActive).ToList();
            oAuthTwitter oaut    = null;
            Users        twtUser = new Users();

            foreach (Domain.Socioboard.Models.TwitterAccount itemTwt in lstAccRepo)
            {
                oaut                   = new oAuthTwitter();
                oaut.AccessToken       = itemTwt.oAuthToken;
                oaut.AccessTokenSecret = itemTwt.oAuthSecret;
                oaut.TwitterScreenName = itemTwt.twitterScreenName;
                oaut.TwitterUserId     = itemTwt.twitterUserId;
                oaut.ConsumerKey       = _appSettings.twitterConsumerKey;
                oaut.ConsumerKeySecret = _appSettings.twitterConsumerScreatKey;
                JArray jarresponse = twtUser.Get_Followers_ById(oaut, itemTwt.twitterUserId);
                JArray user_data   = JArray.Parse(jarresponse[0]["ids"].ToString());
                foreach (var items in user_data)
                {
                    string userid      = items.ToString();
                    JArray userprofile = twtUser.Get_Users_LookUp(oaut, userid);
                    foreach (var item in userprofile)
                    {
                        Domain.Socioboard.Models.TwitterMutualFans objTwitterFollowers = new Domain.Socioboard.Models.TwitterMutualFans();
                        objTwitterFollowers.screen_name       = item["screen_name"].ToString();
                        objTwitterFollowers.name              = item["name"].ToString();
                        objTwitterFollowers.description       = item["description"].ToString();
                        objTwitterFollowers.followers         = item["followers_count"].ToString();
                        objTwitterFollowers.following         = item["friends_count"].ToString();
                        objTwitterFollowers.location          = item["location"].ToString();
                        objTwitterFollowers.profile_image_url = item["profile_image_url"].ToString();
                        lstfollowerlist.Add(objTwitterFollowers);
                    }
                }
            }
            return(lstfollowerlist);
        }