Ejemplo n.º 1
0
 public static BaseInstaUser InitInsta(SocialUserType type, string username, string password, IRequestService reqRes, IDataStringService dataStrSrv)
 {
     switch (type)
     {
         case SocialUserType.Instagram:
             return _instaUser ?? (_instaUser = new InstagramUser(Properties.Settings.Default.InstaClientKey,
         Properties.Settings.Default.InstaClientId, Driver.PhantomInstance,username,password, reqRes, dataStrSrv));
         default:
             throw new Exception("Unknown user type");
     }
 }
Ejemplo n.º 2
0
        public static BaseInstaUser InitInsta(SocialUserType type, string username, string password, IRequestService reqRes, IDataStringService dataStrSrv)
        {
            switch (type)
            {
            case SocialUserType.Instagram:
                return(_instaUser ?? (_instaUser = new InstagramUser(Properties.Settings.Default.InstaClientKey,
                                                                     Properties.Settings.Default.InstaClientId, Driver.PhantomInstance, username, password, reqRes, dataStrSrv)));

            default:
                throw new Exception("Unknown user type");
            }
        }
        private List <SocialUser> LoadSocialUsers(SocialUserType type, SocialUserFilter filter)
        {
            List <SocialUser> users = new List <SocialUser>();

            //Create the endpoint for the REST call
            string endpoint;

            if (type == SocialUserType.Followed)
            {
                endpoint = hdnHostWeb.Value + "/_api/social.following/my/Followed(types=1)";
            }
            else
            {
                endpoint = hdnHostWeb.Value + "/_api/social.following/my/Followers";
            }

            //Make the request
            XDocument responseDoc = GetDataREST(endpoint);

            //Parse the response
            XNamespace d      = "http://schemas.microsoft.com/ado/2007/08/dataservices";
            XNamespace m      = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";
            XNamespace georss = "http://www.georss.org/georss";
            XNamespace gml    = "http://www.opengis.net/gml";

            var followedUsers = from e in responseDoc.Root.Descendants(d + "element")
                                select new
            {
                AccountName = e.Element(d + "AccountName").Value.Split('|')[2],
                Name        = e.Element(d + "Name").Value,
                ImageUrl    = e.Element(d + "ImageUri").Value
            };

            //Build a collection of users
            foreach (var followedUser in followedUsers)
            {
                SocialUser user = new SocialUser();
                user.AccountName = followedUser.AccountName;
                user.Name        = followedUser.Name;
                user.ImageUrl    = followedUser.ImageUrl;
                users.Add(user);
            }

            //Filter the users
            return(FilterFollowed(users, filter));
        }
        private List <SocialUser> LoadSocialUsers(SocialUserType type, SocialUserFilter filter)
        {
            List <SocialUser> users = new List <SocialUser>();

            using (ClientContext ctx = TokenHelper.GetClientContextWithContextToken(hdnHostWeb.Value, hdnContextToken.Value, Request.Url.Authority))
            {
                //Get social users
                ClientResult <SocialActor[]> socialActors     = null;
                SocialFollowingManager       followingManager = new SocialFollowingManager(ctx);
                ctx.Load(followingManager);

                if (type == SocialUserType.Follower)
                {
                    socialActors = followingManager.GetFollowers();
                }
                if (type == SocialUserType.Followed)
                {
                    socialActors = followingManager.GetFollowed(SocialActorTypes.Users);
                }

                ctx.ExecuteQuery();

                //Build a collection of users
                foreach (var socialActor in socialActors.Value)
                {
                    SocialUser user = new SocialUser();
                    user.AccountName = socialActor.AccountName;
                    user.Name        = socialActor.Name;
                    user.ImageUrl    = socialActor.ImageUri;
                    users.Add(user);
                }
            }

            //Filter the users
            return(FilterFollowed(users, filter));
        }
        private List<SocialUser> LoadSocialUsers(SocialUserType type, SocialUserFilter filter)
        {
            List<SocialUser> users = new List<SocialUser>();

            //Create the endpoint for the REST call
            string endpoint;
            if (type == SocialUserType.Followed)
                endpoint = hdnHostWeb.Value + "/_api/social.following/my/Followed(types=1)";
            else
                endpoint = hdnHostWeb.Value + "/_api/social.following/my/Followers";

            //Make the request
            XDocument responseDoc = GetDataREST(endpoint);

            //Parse the response
            XNamespace d = "http://schemas.microsoft.com/ado/2007/08/dataservices";
            XNamespace m = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";
            XNamespace georss = "http://www.georss.org/georss";
            XNamespace gml = "http://www.opengis.net/gml";

            var followedUsers = from e in responseDoc.Root.Descendants(d + "element")
                                select new
                                {
                                    AccountName = e.Element(d + "AccountName").Value.Split('|')[2],
                                    Name = e.Element(d + "Name").Value,
                                    ImageUrl = e.Element(d + "ImageUri").Value
                                };

            //Build a collection of users
            foreach (var followedUser in followedUsers)
            {
                SocialUser user = new SocialUser();
                user.AccountName = followedUser.AccountName;
                user.Name = followedUser.Name;
                user.ImageUrl = followedUser.ImageUrl;
                users.Add(user);
            }

            //Filter the users
            return FilterFollowed(users, filter);
        }
        private List<SocialUser> LoadSocialUsers(SocialUserType type, SocialUserFilter filter)
        {
            List<SocialUser> users = new List<SocialUser>();

            using (ClientContext ctx = TokenHelper.GetClientContextWithContextToken(hdnHostWeb.Value, hdnContextToken.Value, Request.Url.Authority))
            {
                //Get social users
                ClientResult<SocialActor[]> socialActors = null;
                SocialFollowingManager followingManager = new SocialFollowingManager(ctx);
                ctx.Load(followingManager);

                if (type == SocialUserType.Follower)
                    socialActors = followingManager.GetFollowers();
                if (type == SocialUserType.Followed)
                    socialActors = followingManager.GetFollowed(SocialActorTypes.Users);

                ctx.ExecuteQuery();

                //Build a collection of users
                foreach (var socialActor in socialActors.Value)
                {
                    SocialUser user = new SocialUser();
                    user.AccountName = socialActor.AccountName;
                    user.Name = socialActor.Name;
                    user.ImageUrl = socialActor.ImageUri;
                    users.Add(user);
                }
            }

            //Filter the users
            return FilterFollowed(users, filter);
        }