public void AuthenticateInstagram(object sender, EventArgs e)
        {
            GlobusInstagramLib.Authentication.ConfigurationIns config = new GlobusInstagramLib.Authentication.ConfigurationIns("https://instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"].ToString(), ConfigurationManager.AppSettings["InstagramClientSec"].ToString(), ConfigurationManager.AppSettings["InstagramCallBackURL"].ToString(), "https://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
            oAuthInstagram _api = oAuthInstagram.GetInstance(config);

            Response.Redirect(_api.AuthGetUrl("likes+comments+basic+relationships"));
        }
        public string GetInstagramRedirectUrl(string consumerKey, string consumerSecret, string CallBackUrl)
        {
            string rest = string.Empty;

            GlobusInstagramLib.Authentication.ConfigurationIns config = new GlobusInstagramLib.Authentication.ConfigurationIns("https://instagram.com/oauth/authorize/", consumerKey, consumerSecret, CallBackUrl, "https://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
            oAuthInstagram _api = oAuthInstagram.GetInstance(config);

            rest = _api.AuthGetUrl("likes+comments+basic+relationships");
            return(rest);
        }
        public string AddComment(string UserId, string FeedId, string Text, string InstagramId)
        {
            GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"], ConfigurationManager.AppSettings["InstagramClientSec"], ConfigurationManager.AppSettings["RedirectUrl"], "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
            oAuthInstagram _api = new oAuthInstagram();

            _api = oAuthInstagram.GetInstance(configi);
            objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, Guid.Parse(UserId));
            CommentController objComment = new CommentController();

            bool ret = objComment.PostCommentAdd(FeedId, Text, objInstagramAccount.AccessToken);

            return("");
        }
 public void InstagramRedirect(object sender, EventArgs e)
 {
     if (ddlGroup.SelectedItem.Text != "Select")
     {
         GlobusInstagramLib.Authentication.ConfigurationIns config = new GlobusInstagramLib.Authentication.ConfigurationIns("https://instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"].ToString(), ConfigurationManager.AppSettings["InstagramClientSec"].ToString(), ConfigurationManager.AppSettings["InstagramCallBackURL"].ToString(), "https://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
         oAuthInstagram _api = oAuthInstagram.GetInstance(config);
         Session["UserAndGroupsForFacebook"] = "instagram";
         Response.Redirect(_api.AuthGetUrl("likes+comments+basic+relationships"));
     }
     else
     {
         Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "test", "<script type=\"text/javascript\">alert(\"Select the group to add profiles\")</script>", false);
     }
 }
Example #5
0
        public string getInstagramData(string UserId, string InstagramId)
        {
            Guid userId = Guid.Parse(UserId);
            InstagramAccountRepository objInstagramAccountRepository = new InstagramAccountRepository();

            //LinkedInAccountRepository objLinkedInAccountRepository = new LinkedInAccountRepository();

            Domain.Socioboard.Domain.InstagramAccount          objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, userId);
            GlobusInstagramLib.Authentication.ConfigurationIns configi             = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"], ConfigurationManager.AppSettings["InstagramClientSec"], ConfigurationManager.AppSettings["RedirectUrl"], "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
            oAuthInstagram _api = new oAuthInstagram();

            _api = oAuthInstagram.GetInstance(configi);
            GetIntagramImages(objInstagramAccount);
            return("Instagram Info is Updated successfully");
        }
        public InstagramMedia[] GeographyMedia(string geographyid, string accessToken)
        {
            oAuthInstagram oAuthIn = new oAuthInstagram();
            string         url     = oAuthIn.Configuration.ApiBaseUrl + "geographies/" + geographyid + "/media/recent?access_token=" + accessToken;
            string         json    = oAuthIn.RequestGetToUrl(url, oAuthIn.Configuration.Proxy);

            if (string.IsNullOrEmpty(json))
            {
                return(new InstagramMedia[0]);
            }

            InstagramResponse <InstagramMedia[]> res = Base.DeserializeObject <InstagramResponse <InstagramMedia[]> >(json);

            return(res.data);
        }
        public string InstagramLikeUnLike(string LikeCount, string IsLike, string FeedId, string InstagramId, string UserId)
        {
            string str = string.Empty;

            GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"], ConfigurationManager.AppSettings["InstagramClientSec"], ConfigurationManager.AppSettings["RedirectUrl"], "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
            oAuthInstagram _api = new oAuthInstagram();

            _api = oAuthInstagram.GetInstance(configi);
            try
            {
                objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, Guid.Parse(UserId));

                LikesController objlikes   = new LikesController();
                int             islike     = Convert.ToInt32(IsLike);
                int             LikeCounts = Convert.ToInt32(LikeCount);

                if (islike == 0)
                {
                    islike = 1;
                    bool dd = objlikes.PostUserLike(FeedId, objInstagramAccount.AccessToken);
                    LikeCounts++;
                    objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts);
                    str = "unlike";
                }
                else
                {
                    islike = 0;
                    bool i = objlikes.DeleteLike(FeedId, objInstagramAccount.AccessToken);
                    LikeCounts = LikeCounts - 1;
                    objInstagramFeedRepository.UpdateLikesOfProfile(FeedId, islike, LikeCounts);
                    str = "like";
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            return(str);
        }
Example #8
0
        public string getInstagramData(string UserId, string InstagramId)
        {
            Guid userId = Guid.Parse(UserId);
            InstagramAccountRepository objInstagramAccountRepository = new InstagramAccountRepository();

            //LinkedInAccountRepository objLinkedInAccountRepository = new LinkedInAccountRepository();

            Domain.Socioboard.Domain.InstagramAccount          objInstagramAccount = objInstagramAccountRepository.getInstagramAccountDetailsById(InstagramId, userId);
            GlobusInstagramLib.Authentication.ConfigurationIns configi             = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"], ConfigurationManager.AppSettings["InstagramClientSec"], ConfigurationManager.AppSettings["RedirectUrl"], "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
            oAuthInstagram _api = new oAuthInstagram();

            _api = oAuthInstagram.GetInstance(configi);
            GetIntagramImages(objInstagramAccount);
            #region UpdateTeammemberprofile
            Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
            objTeamMemberProfile.ProfileName   = objInstagramAccount.InsUserName;
            objTeamMemberProfile.ProfilePicUrl = objInstagramAccount.ProfileUrl;
            objTeamMemberProfile.ProfileId     = objInstagramAccount.InstagramId;
            objTeamMemberProfileRepository.updateTeamMemberbyprofileid(objTeamMemberProfile);
            #endregion
            return("Instagram Info is Updated successfully");
        }
Example #9
0
 public void AuthenticateInstagram(object sender, EventArgs e)
 {
     try
     {
         int profilecount = (int)Session["ProfileCount"];
         int totalaccount = (int)Session["TotalAccount"];
         if (profilecount < totalaccount)
         {
             GlobusInstagramLib.Authentication.ConfigurationIns config = new GlobusInstagramLib.Authentication.ConfigurationIns("https://instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"].ToString(), ConfigurationManager.AppSettings["InstagramClientSec"].ToString(), ConfigurationManager.AppSettings["InstagramCallBackURL"].ToString(), "https://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
             oAuthInstagram _api = oAuthInstagram.GetInstance(config);
             Response.Redirect(_api.AuthGetUrl("likes+comments+basic+relationships"));
         }
         else
         {
             Response.Write("<script>SimpleMessageAlert('Change the Plan to Add More Accounts');</script>");
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex.Message);
     }
 }
Example #10
0
        public void AuthenticateInstagram(object sender, EventArgs e)
        {
            try
            {
                GroupRepository        objGroupRepository = new GroupRepository();
                SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"];
                Groups lstDetails           = objGroupRepository.getGroupName(team.GroupId);

                try
                {
                    int profilecount = (int)Session["ProfileCount"];
                    int totalaccount = (int)Session["TotalAccount"];
                    if (lstDetails.GroupName == "Socioboard")
                    {
                        if (profilecount < totalaccount)
                        {
                            GlobusInstagramLib.Authentication.ConfigurationIns config = new GlobusInstagramLib.Authentication.ConfigurationIns("https://instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"].ToString(), ConfigurationManager.AppSettings["InstagramClientSec"].ToString(), ConfigurationManager.AppSettings["InstagramCallBackURL"].ToString(), "https://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
                            oAuthInstagram _api = oAuthInstagram.GetInstance(config);
                            InstagramConnect.HRef = _api.AuthGetUrl("likes+comments+basic+relationships");
                            Response.Redirect(_api.AuthGetUrl("likes+comments+basic+relationships"));
                        }
                        else
                        {
                            // Response.Write("<script>SimpleMessageAlert('Change the Plan to Add More Accounts');</script>");
                            ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Change the Plan to Add More Accounts');", true);
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
        }
        public static string AddInstagramAccount(string client_id, string client_secret, string redirect_uri, string code, long userId, long groupId, Model.DatabaseRepository dbr, ILogger _logger, Helper.Cache _redisCache, Helper.AppSettings _appSettings)
        {
            string           ret      = string.Empty;
            oAuthInstagram   objInsta = new oAuthInstagram();
            ConfigurationIns configi  = new ConfigurationIns("https://api.instagram.com/oauth/authorize/", client_id, client_secret, redirect_uri, "https://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
            oAuthInstagram   _api     = new oAuthInstagram();

            _api = oAuthInstagram.GetInstance(configi);
            AccessToken access = new AccessToken();

            access = _api.AuthGetAccessToken(code);
            UserController objusercontroller = new UserController();

            if (access != null)
            {
                Domain.Socioboard.Models.Instagramaccounts Instagramaccounts = new Domain.Socioboard.Models.Instagramaccounts();
                Domain.Socioboard.Models.Instagramaccounts objInstagramAccount;
                #region InstagramAccount
                InstagramResponse <User> objuser = objusercontroller.GetUserDetails(access.user.id, access.access_token);

                objInstagramAccount             = new Domain.Socioboard.Models.Instagramaccounts();
                objInstagramAccount.AccessToken = access.access_token;
                objInstagramAccount.InstagramId = access.user.id;
                try
                {
                    objInstagramAccount.bio = access.user.bio;
                }
                catch {
                    objInstagramAccount.bio = "";
                }
                try
                {
                    objInstagramAccount.ProfileUrl = access.user.profile_picture;
                }
                catch (Exception ex)
                {
                    _logger.LogError("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
                }
                try
                {
                    objInstagramAccount.InsUserName = access.user.username;
                }
                catch (Exception ex)
                {
                    _logger.LogError("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
                }
                try
                {
                    objInstagramAccount.TotalImages = objuser.data.counts.media;
                }
                catch (Exception ex)
                {
                    _logger.LogError("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
                }
                try
                {
                    objInstagramAccount.FollowedBy = objuser.data.counts.followed_by;
                }
                catch (Exception ex)
                {
                    _logger.LogError("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
                }
                try
                {
                    objInstagramAccount.Followers = objuser.data.counts.follows;
                }
                catch (Exception ex)
                {
                    _logger.LogError("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
                }
                objInstagramAccount.UserId     = userId;
                objInstagramAccount.IsActive   = true;
                objInstagramAccount.lastUpdate = DateTime.UtcNow;
                if (objInstagramAccount.InstagramId != null)
                {
                    Instagramaccounts = Api.Socioboard.Repositories.InstagramRepository.getInstagramAccount(objInstagramAccount.InstagramId, _redisCache, dbr);
                    if (Instagramaccounts != null && Instagramaccounts.IsActive == true)
                    {
                        return("This Account is added by some body else.");
                    }
                }
                else
                {
                    return("Issue while fetching instagram userId");
                }

                if (Instagramaccounts == null)
                {
                    int isSaved = dbr.Add <Domain.Socioboard.Models.Instagramaccounts>(objInstagramAccount);
                    if (isSaved == 1)
                    {
                        List <Domain.Socioboard.Models.Instagramaccounts> lstinsAcc = dbr.Find <Domain.Socioboard.Models.Instagramaccounts>(t => t.InstagramId.Equals(objInstagramAccount.InstagramId)).ToList();
                        if (lstinsAcc != null && lstinsAcc.Count() > 0)
                        {
                            isSaved = GroupProfilesRepository.AddGroupProfile(groupId, lstinsAcc.First().InstagramId, lstinsAcc.First().InsUserName, userId, lstinsAcc.First().ProfileUrl, Domain.Socioboard.Enum.SocialProfileType.Instagram, dbr);
                            if (isSaved == 1)
                            {
                                _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId);
                                _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);

                                GetInstagramSelfFeeds(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _appSettings);
                                GetInstagramUserDetails(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _redisCache, dbr);
                                GetInstagramFollowing(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings);
                                GetInstagramFollower(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings);
                                new Thread(delegate()
                                {
                                    GetInstagramPostLikes(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings);
                                    GetInstagramPostComments(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _appSettings);
                                }).Start();

                                return("Added_Successfully");
                            }
                        }
                    }
                }
                else
                {
                    objInstagramAccount.id = Instagramaccounts.id;
                    int isSaved = dbr.Update <Domain.Socioboard.Models.Instagramaccounts>(objInstagramAccount);
                    if (isSaved == 1)
                    {
                        List <Domain.Socioboard.Models.Instagramaccounts> lstinsAcc = dbr.Find <Domain.Socioboard.Models.Instagramaccounts>(t => t.InstagramId.Equals(objInstagramAccount.InstagramId)).ToList();
                        if (lstinsAcc != null && lstinsAcc.Count() > 0)
                        {
                            isSaved = GroupProfilesRepository.AddGroupProfile(groupId, lstinsAcc.First().InstagramId, lstinsAcc.First().InsUserName, userId, lstinsAcc.First().ProfileUrl, Domain.Socioboard.Enum.SocialProfileType.Instagram, dbr);
                            if (isSaved == 1)
                            {
                                _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId);
                                _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId);


                                //todo : codes to update feeds
                                GetInstagramSelfFeeds(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _appSettings);
                                GetInstagramUserDetails(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _redisCache, dbr);
                                GetInstagramFollowing(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings);
                                GetInstagramFollower(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings);
                                new Thread(delegate()
                                {
                                    GetInstagramPostLikes(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings);
                                    GetInstagramPostComments(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _appSettings);
                                }).Start();



                                return("Added_Successfully");
                            }
                        }
                    }
                }
            }
            return("issue in access token fetching");

            #endregion
        }
        public void getAccessToken()
        {
            GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"].ToString(), ConfigurationManager.AppSettings["InstagramClientSec"].ToString(), ConfigurationManager.AppSettings["InstagramCallBackURL"].ToString(), "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
            SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository();
            SocialProfile            socioprofile     = new SocialProfile();

            _api = oAuthInstagram.GetInstance(configi);
            AccessToken access = new AccessToken();
            string      code   = Request.QueryString["code"].ToString();

            SocioBoard.Domain.User user = (SocioBoard.Domain.User)Session["LoggedUser"];
            access = _api.AuthGetAccessToken(code);

            UserController objusercontroller = new UserController();
            InstagramResponse <GlobusInstagramLib.App.Core.User> objuser = objusercontroller.GetUserDetails(access.user.id, access.access_token);

            InstagramAccount objInsAccount = new InstagramAccount();

            objInsAccount.AccessToken = access.access_token;
            //objInsAccount.FollowedBy=access.user.
            objInsAccount.InstagramId = access.user.id;
            objInsAccount.ProfileUrl  = access.user.profile_picture;
            objInsAccount.InsUserName = access.user.username;
            objInsAccount.TotalImages = objuser.data.counts.media;
            objInsAccount.FollowedBy  = objuser.data.counts.followed_by;
            objInsAccount.Followers   = objuser.data.counts.follows;
            objInsAccount.UserId      = user.Id;

            socioprofile.UserId        = user.Id;
            socioprofile.ProfileType   = "instagram";
            socioprofile.ProfileId     = access.user.id;
            socioprofile.ProfileStatus = 1;
            socioprofile.ProfileDate   = DateTime.Now;
            socioprofile.Id            = Guid.NewGuid();

            if (objInsRepo.checkInstagramUserExists(access.user.id, user.Id))
            {
                HttpContext.Current.Session["alreadyexist"] = objInsAccount;
                objInsRepo.updateInstagramUser(objInsAccount);
                if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                {
                    socioprofilerepo.addNewProfileForUser(socioprofile);
                }
            }
            else
            {
                objInsRepo.addInstagramUser(objInsAccount);
                if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                {
                    socioprofilerepo.addNewProfileForUser(socioprofile);
                    GroupRepository        objGroupRepository = new GroupRepository();
                    SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)HttpContext.Current.Session["GroupName"];
                    Groups lstDetails           = objGroupRepository.getGroupName(team.GroupId);
                    if (lstDetails.GroupName == "Socioboard")
                    {
                        TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository();
                        TeamMemberProfile           teammemberprofile = new TeamMemberProfile();
                        teammemberprofile.Id               = Guid.NewGuid();
                        teammemberprofile.TeamId           = team.Id;
                        teammemberprofile.ProfileId        = socioprofile.ProfileId;
                        teammemberprofile.ProfileType      = "instagram";
                        teammemberprofile.StatusUpdateDate = DateTime.Now;

                        objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile);
                    }
                }
            }
            string messages = getIntagramImages(objInsAccount);


            Response.Write(messages);
        }
        public string AddInstagramAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code)
        {
            string         ret      = string.Empty;
            oAuthInstagram objInsta = new oAuthInstagram();

            GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", client_id, client_secret, redirect_uri, "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
            oAuthInstagram _api = new oAuthInstagram();

            _api = oAuthInstagram.GetInstance(configi);
            AccessToken access = new AccessToken();

            access = _api.AuthGetAccessToken(code);
            #region InstagramAccount
            UserController objusercontroller = new UserController();
            InstagramResponse <GlobusInstagramLib.App.Core.User> objuser = objusercontroller.GetUserDetails(access.user.id, access.access_token);
            objInstagramAccount             = new Domain.Myfashion.Domain.InstagramAccount();
            objInstagramAccount.AccessToken = access.access_token;
            objInstagramAccount.InstagramId = access.user.id;
            try
            {
                objInstagramAccount.ProfileUrl = access.user.profile_picture;
            }
            catch (Exception ex)
            {
                logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
            }
            try
            {
                objInstagramAccount.InsUserName = access.user.username;
            }
            catch (Exception ex)
            {
                logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
            }
            try
            {
                objInstagramAccount.TotalImages = objuser.data.counts.media;
            }
            catch (Exception ex)
            {
                logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
            }
            try
            {
                objInstagramAccount.FollowedBy = objuser.data.counts.followed_by;
            }
            catch (Exception ex)
            {
                logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
            }
            try
            {
                objInstagramAccount.Followers = objuser.data.counts.follows;
            }
            catch (Exception ex)
            {
                logger.Error("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace);
            }
            objInstagramAccount.UserId = Guid.Parse(UserId);
            #endregion


            if (!objInstagramAccountRepository.checkInstagramUserExists(objInstagramAccount.InstagramId, Guid.Parse(UserId)))
            {
                objInstagramAccountRepository.addInstagramUser(objInstagramAccount);
                #region Add TeamMemberProfile
                Domain.Myfashion.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                Domain.Myfashion.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Myfashion.Domain.TeamMemberProfile();
                objTeamMemberProfile.Id               = Guid.NewGuid();
                objTeamMemberProfile.TeamId           = objTeam.Id;
                objTeamMemberProfile.Status           = 1;
                objTeamMemberProfile.ProfileType      = "instagram";
                objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                objTeamMemberProfile.ProfileId        = objInstagramAccount.InstagramId;

                //Modified [13-02-15]
                objTeamMemberProfile.ProfilePicUrl = objInstagramAccount.ProfileUrl;
                objTeamMemberProfile.ProfileName   = objInstagramAccount.InsUserName;

                objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                #endregion
                #region SocialProfile
                Domain.Myfashion.Domain.SocialProfile objSocialProfile = new Domain.Myfashion.Domain.SocialProfile();
                objSocialProfile.Id            = Guid.NewGuid();
                objSocialProfile.ProfileType   = "instagram";
                objSocialProfile.ProfileId     = objInstagramAccount.InstagramId;
                objSocialProfile.UserId        = Guid.Parse(UserId);
                objSocialProfile.ProfileDate   = DateTime.Now;
                objSocialProfile.ProfileStatus = 1;
                #endregion
                #region Add SocialProfile
                if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                {
                    objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                }

                #endregion
                ret = "Account Added Successfully";
            }
            else
            {
                ret = "Account already Exist !";
            }

            //GetIntagramImages(objInstagramAccount);
            GetInstagramFeeds(objInstagramAccount);
            return(ret);
        }
Example #14
0
        public void getIntagramImages(object instaId)
        {
            Guid instaid = (Guid)instaId;

            InstagramAccountRepository objIns = new InstagramAccountRepository();
            InstagramResponse <GlobusInstagramLib.App.Core.User[]> userinf  = new InstagramResponse <GlobusInstagramLib.App.Core.User[]>();
            InstagramResponse <GlobusInstagramLib.App.Core.User[]> userinf1 = new InstagramResponse <GlobusInstagramLib.App.Core.User[]>();
            InstagramResponse <InstagramMedia[]> userinf2 = new InstagramResponse <InstagramMedia[]>();
            InstagramResponse <Comment[]>        usercmts = new InstagramResponse <Comment[]>();
            MediaController            objMedia           = new MediaController();
            CommentController          objComment         = new CommentController();
            LikesController            objLikes           = new LikesController();
            InstagramFeedRepository    objInsFeedRepo     = new InstagramFeedRepository();
            InstagramFeed              objFeed            = new InstagramFeed();
            InstagramComment           objinsComment      = new InstagramComment();
            InstagramCommentRepository objInsRepo         = new InstagramCommentRepository();

            GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", ConfigurationManager.AppSettings["InstagramClientKey"].ToString(), ConfigurationManager.AppSettings["InstagramClientSec"].ToString(), ConfigurationManager.AppSettings["InstagramCallBackURL"].ToString(), "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
            oAuthInstagram _api = oAuthInstagram.GetInstance(configi);
            ArrayList      aslt = objIns.getAllInstagramAccountsOfUser(instaid);
            string         html = string.Empty;
            int            i    = 0;

            // string[] allhtmls = new string[aslt.Count];
            string[] allhtmls      = new string[0];
            int      countofimages = 0;

            foreach (InstagramAccount item in aslt)
            {
                try
                {
                    GlobusInstagramLib.Instagram.Core.UsersMethods.Users userInstagram = new GlobusInstagramLib.Instagram.Core.UsersMethods.Users();
                    try
                    {
                        userinf2 = userInstagram.UserRecentMedia(item.InstagramId, string.Empty, string.Empty, "20", string.Empty, string.Empty, item.AccessToken);
                    }
                    catch { }
                }
                catch { }



                if (userinf2 != null)
                {
                    for (int j = 0; j < userinf2.data.Count(); j++)
                    {
                        try
                        {
                            usercmts = objComment.GetComment(userinf2.data[j].id, item.AccessToken);
                            bool liked = false;
                            try
                            {
                                liked = objLikes.LikeToggle(userinf2.data[j].id, item.InstagramId, item.AccessToken);
                            }
                            catch
                            {
                            }
                            int n = usercmts.data.Count();
                            for (int cmt = 0; cmt < usercmts.data.Count(); cmt++)
                            {
                                objinsComment.Comment        = usercmts.data[cmt].text;
                                objinsComment.CommentDate    = usercmts.data[cmt].created_time.ToString();
                                objinsComment.CommentId      = usercmts.data[cmt].id;
                                objinsComment.EntryDate      = DateTime.Now.ToString();
                                objinsComment.FeedId         = userinf2.data[j].id;
                                objinsComment.Id             = Guid.NewGuid();
                                objinsComment.InstagramId    = item.InstagramId;
                                objinsComment.UserId         = item.UserId;
                                objinsComment.FromName       = usercmts.data[cmt].from.full_name;
                                objinsComment.FromProfilePic = usercmts.data[cmt].from.profile_picture;
                                if (!objInsRepo.checkInstagramCommentExists(usercmts.data[cmt].id, item.UserId))
                                {
                                    objInsRepo.addInstagramComment(objinsComment);
                                }
                            }
                            objFeed.EntryDate    = DateTime.Now;
                            objFeed.FeedDate     = userinf2.data[j].created_time.ToString();
                            objFeed.FeedId       = userinf2.data[j].id;
                            objFeed.FeedImageUrl = userinf2.data[j].images.low_resolution.url.ToString();
                            objFeed.InstagramId  = item.InstagramId;
                            objFeed.LikeCount    = userinf2.data[j].likes.count;
                            objFeed.UserId       = item.UserId;
                            if (!objInsFeedRepo.checkInstagramFeedExists(userinf2.data[j].id, item.UserId))
                            {
                                objInsFeedRepo.addInstagramFeed(objFeed);
                            }
                        }
                        catch
                        {
                        }
                        i++;
                    }
                }
                i++;
                //     allhtmls[countofimages] = html;
                html = string.Empty;
                countofimages++;
                break;
            }
            string totalhtml = string.Empty;

            try
            {
                for (int k = 0; k < countofimages; k++)
                {
                    totalhtml = totalhtml + allhtmls[k];
                }
            }
            catch
            {
            }
        }
Example #15
0
        public static int updateInstagramFeeds(Domain.Socioboard.Models.Instagramaccounts insAcc)
        {
            apiHitsCount = 0;
            DatabaseRepository dbr = new DatabaseRepository();

            Domain.Socioboard.Models.Groupprofiles _grpProfile = dbr.Single <Domain.Socioboard.Models.Groupprofiles>(t => t.profileId.Contains(insAcc.InstagramId));
            if (insAcc.lastUpdate.AddHours(1) <= DateTime.UtcNow)
            {
                if (insAcc.IsActive)
                {
                    //  Domain.Socioboard.Models.Instagramaccounts Instagramaccounts = new Domain.Socioboard.Models.Instagramaccounts();
                    Domain.Socioboard.Models.Instagramaccounts objInstagramAccount;
                    UserController   objusercontroller = new UserController();
                    ConfigurationIns configi           = new ConfigurationIns("https://api.instagram.com/oauth/authorize/", "d89b5cfa3796458ebbb2520d70eeb498", "e4663d0a287243f88ac619b5692119c8", "https://www.socioboard.com/InstagramManager/Instagram", "https://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
                    oAuthInstagram   _api = new oAuthInstagram();
                    _api = oAuthInstagram.GetInstance(configi);
                    InstagramResponse <User> objuser = objusercontroller.GetUserDetails(insAcc.InstagramId, insAcc.AccessToken);

                    //  objInstagramAccount = new Domain.Socioboard.Models.Instagramaccounts();


                    if (objuser != null)
                    {
                        try
                        {
                            insAcc.ProfileUrl      = objuser.data.profile_picture;
                            _grpProfile.profilePic = objuser.data.profile_picture;
                        }
                        catch (Exception ex)
                        {
                            insAcc.ProfileUrl      = insAcc.ProfileUrl;
                            _grpProfile.profilePic = insAcc.ProfileUrl;
                        }
                        try
                        {
                            insAcc.TotalImages = objuser.data.counts.media;
                        }
                        catch (Exception ex)
                        {
                            insAcc.TotalImages = insAcc.TotalImages;
                        }
                        try
                        {
                            insAcc.FollowedBy = objuser.data.counts.followed_by;
                        }
                        catch (Exception ex)
                        {
                            insAcc.FollowedBy = insAcc.FollowedBy;
                        }
                        try
                        {
                            insAcc.Followers = objuser.data.counts.follows;
                        }
                        catch (Exception ex)
                        {
                            insAcc.Followers = insAcc.Followers;
                        }
                        try
                        {
                            insAcc.bio = objuser.data.bio;
                        }
                        catch (Exception ex)
                        {
                            insAcc.bio = insAcc.bio;
                        }
                        dbr.Update <Domain.Socioboard.Models.Groupprofiles>(_grpProfile);
                        dbr.Update <Domain.Socioboard.Models.Instagramaccounts>(insAcc);
                    }
                    while (apiHitsCount < MaxapiHitsCount)
                    {
                        try
                        {
                            GetInstagramSelfFeeds(insAcc.InstagramId, insAcc.AccessToken);
                        }
                        catch { }
                        try
                        {
                            GetInstagramUserDetails(insAcc.InstagramId, insAcc.AccessToken, insAcc);
                        }
                        catch { }
                        try
                        {
                            GetInstagramPostLikes(insAcc.InstagramId, insAcc.AccessToken);
                        }
                        catch { }
                        try
                        {
                            GetInstagramPostComments(insAcc.InstagramId, insAcc.AccessToken);
                        }
                        catch { }
                        try
                        {
                            GetInstagramFollowing(insAcc.InstagramId, insAcc.AccessToken, 1);
                        }
                        catch { }
                        try
                        {
                            GetInstagramFollower(insAcc.InstagramId, insAcc.AccessToken, 1);
                        }
                        catch { }
                    }
                    insAcc.lastUpdate = DateTime.UtcNow;
                    dbr.Update <Domain.Socioboard.Models.Instagramaccounts>(insAcc);
                }
            }
            else
            {
                apiHitsCount = 0;
            }

            return(0);
        }