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);
            
            GetInstagramFeeds(objInstagramAccount);
            GetInstagramUserDetails(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken);
            GetInstagramFollowing(objInstagramAccount.UserId.ToString(), objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 0);
            GetInstagramFollower(objInstagramAccount.UserId.ToString(), objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 0);
            GetInstagramPostLikes(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 0);
            GetInstagramPostComments(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken);
            //GetInstagramUserPosts(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken);
            #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";
        }
        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"));
        }
Exemple #3
0
        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 bool likefunction(string id, string userid, string accesstoken)
 {
     oAuthInstagram _api;
     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/", "");
     _api = oAuthInstagram.GetInstance(configi);
     LikesController objlikes = new LikesController();
     bool dd = objlikes.PostUserLike(id, userid, accesstoken);
     return dd;
 }
        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 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))
            {
                objInsRepo.updateInstagramUser(objInsAccount);
                if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                {
                    socioprofilerepo.addNewProfileForUser(socioprofile);
                }
            }
            else
            {
                objInsRepo.addInstagramUser(objInsAccount);
                if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                {
                    socioprofilerepo.addNewProfileForUser(socioprofile);
                }
            }
       string messages =     getIntagramImages(objInsAccount);

          
            Response.Write(messages);
        }
        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("");
        }
Exemple #8
0
        public static oAuthInstagram GetInstance(ConfigurationIns configuration)
        {
            lock (threadlock)
            {
                if (_sharedInstance == null)
                {
                    _sharedInstance = new oAuthInstagram();
                    _sharedInstance.Configuration = configuration;
                }
            }

            return(_sharedInstance);
        }
        public static oAuthInstagram GetInstance(ConfigurationIns configuration)
        {
            lock (threadlock)
            {
                if (_sharedInstance == null)
                {
                    _sharedInstance = new oAuthInstagram();
                    _sharedInstance.Configuration = configuration;

                }
            }

            return _sharedInstance;
        }
 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);
     }
 }
Exemple #11
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 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);
        }
Exemple #13
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");
        }
Exemple #14
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);
     }
 }
Exemple #15
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 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
            {
            }
          
        }
Exemple #17
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 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 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;
        }
        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 AddComment(string UserId, string FeedId, string Text, string InstagramId)
        {
            MongoRepository instagarmCommentRepo = new MongoRepository("InstagramComment");
            Domain.Socioboard.MongoDomain.InstagramComment _InstagramComment = new Domain.Socioboard.MongoDomain.InstagramComment();
            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();
            string ret = objComment.PostCommentAdd(FeedId, Text, objInstagramAccount.AccessToken);

            if (!string.IsNullOrEmpty(ret))
            {
                try
                {
                    JObject JData = JObject.Parse(ret);
                    string commentid = JData["data"]["id"].ToString();
                    string time = JData["data"]["created_time"].ToString();
                    string profilepic = JData["data"]["from"]["profile_picture"].ToString();
                    string username = JData["data"]["from"]["username"].ToString();
                    _InstagramComment.Id = ObjectId.GenerateNewId();
                    _InstagramComment.strId = ObjectId.GenerateNewId().ToString();
                    _InstagramComment.FeedId = FeedId;
                    _InstagramComment.InstagramId = InstagramId;
                    _InstagramComment.FromProfilePic = profilepic;
                    _InstagramComment.FromName = username;
                    _InstagramComment.CommentDate = time;
                    _InstagramComment.Comment = Text;
                    _InstagramComment.CommentId = commentid;
                    //objInstagramCommentRepository.addInstagramComment(_InstagramComment);

                    instagarmCommentRepo.Add(_InstagramComment);
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                    return null;
                }

            }
            else { return null; }

            return new JavaScriptSerializer().Serialize(_InstagramComment);


        }
Exemple #22
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
            {
            }
        }
 public string GetInstagramRedirectUrl(string consumerKey, string consumerSecret, string CallBackUrl)
 {
     logger.Error("GetInstagramRedirectUrl");
     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");
     logger.Error("GetInstagramRedirectUrl => " + rest);
     return rest;
 }
        public string InstagramSearch(string keyword, string WebUrl)
        {
            string response = string.Empty;
            string resId = string.Empty;
            try
            {
                GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", "f5f052ccbdf94df490020f852863141b", "6c8ac0efa42c4c918bf33835fc98a793", "http://localhost:9821/InstagramManager/Instagram", "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
                oAuthInstagram _api = new oAuthInstagram();
                _api = oAuthInstagram.GetInstance(configi);
                AccessToken access = new AccessToken();
                //ArrayList arrList = instagramRepo.getAllInstagramAccounts();
                //Domain.Socioboard.Domain.InstagramAccount instaacc = (Domain.Socioboard.Domain.InstagramAccount)arrList[0];
                //string tk = instaacc.AccessToken;
                string tk = "422418207.d89b5cf.7d26304ef400404d816218f2318f6cc6";
                //TODO : Access token Logic
                response = _api.WebRequest(oAuthInstagram.Method.GET, "https://api.instagram.com/v1/users/search?q=" + keyword + "&access_token=" + tk, null);
                if (!response.StartsWith("["))
                    response = "[" + response + "]";
                JArray Instagramaccarray = JArray.Parse(response);
                foreach (var acc in Instagramaccarray)
                {
                    var data = acc["data"];

                    foreach (var page in data)
                    {
                        try
                        {

                            if (page["website"].ToString().Equals(WebUrl))
                            {
                                resId = page["id"].ToString();
                                break;
                            }
                        }
                        catch (Exception e)
                        {
                        }
                    }
                }

            }
            catch (Exception ex)
            {

            }
            if (string.IsNullOrEmpty(resId))
            {
                return string.Empty;
            }
            return InstagramSingleUser(resId);
        }
Exemple #25
0
        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.Socioboard.Domain.InstagramAccount();
            objInstagramAccount.AccessToken = access.access_token;
            objInstagramAccount.InstagramId = access.user.id;
            objInstagramAccount.ProfileUrl = access.user.profile_picture;
            objInstagramAccount.InsUserName = access.user.username;
            objInstagramAccount.TotalImages = objuser.data.counts.media;
            objInstagramAccount.FollowedBy = objuser.data.counts.followed_by;
            objInstagramAccount.Followers = objuser.data.counts.follows;
            objInstagramAccount.UserId = Guid.Parse(UserId); 
            #endregion


            if (!objInstagramAccountRepository.checkInstagramUserExists(objInstagramAccount.InstagramId,Guid.Parse(UserId)))
                {
                    objInstagramAccountRepository.addInstagramUser(objInstagramAccount);
                    #region Add TeamMemberProfile
                    Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                    Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.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.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.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);
            return ret;
        }
        public string InstagramSingleUser(string UserId)
        {
            string response = string.Empty;
            try
            {
                GlobusInstagramLib.Authentication.ConfigurationIns configi = new GlobusInstagramLib.Authentication.ConfigurationIns("https://api.instagram.com/oauth/authorize/", "f5f052ccbdf94df490020f852863141b", "6c8ac0efa42c4c918bf33835fc98a793", "http://localhost:9821/InstagramManager/Instagram", "http://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", "");
                oAuthInstagram _api = new oAuthInstagram();
                _api = oAuthInstagram.GetInstance(configi);
                AccessToken access = new AccessToken();
                //ArrayList arrList = instagramRepo.getAllInstagramAccounts();
                //Domain.Socioboard.Domain.InstagramAccount instaacc = (Domain.Socioboard.Domain.InstagramAccount)arrList[1];
                //string tk = instaacc.AccessToken;
                string tk = "422418207.d89b5cf.7d26304ef400404d816218f2318f6cc6";
                response = _api.WebRequest(oAuthInstagram.Method.GET, "https://api.instagram.com/v1/users/" + UserId + "/?access_token=" + tk, null);


            }
            catch (Exception ex)
            {

            }

            return response;
        }
        public string InstagramLikeUnLike(string LikeCount, string IsLike, string FeedId, string InstagramId, string UserId)
        {

            MongoRepository instagramFeedRepo = new MongoRepository("InstagramFeed");
            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";

                }

                FilterDefinition<BsonDocument> filter = new BsonDocument("FeedId", FeedId);
                var update = Builders<BsonDocument>.Update.Set("IsLike", islike).Set("LikeCount", LikeCounts);
                instagramFeedRepo.Update<Domain.Socioboard.MongoDomain.InstagramFeed>(update, filter);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            return str;
        }
        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);

            


            UserController objusercontroller = new UserController();
            try
            {
                logger.Error("AddInstagramAccount == >>" + access.access_token);
                #region InstagramAccount
                InstagramResponse<GlobusInstagramLib.App.Core.User> objuser = objusercontroller.GetUserDetails(access.user.id, access.access_token);

                objInstagramAccount = new Domain.Socioboard.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.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                    //Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.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);

                    Domain.Socioboard.Domain.GroupProfile grpProfile = new Domain.Socioboard.Domain.GroupProfile();
                    grpProfile.Id = Guid.NewGuid();
                    grpProfile.EntryDate = DateTime.UtcNow;
                    grpProfile.GroupId = Guid.Parse(GroupId);
                    grpProfile.GroupOwnerId = Guid.Parse(UserId);
                    grpProfile.ProfileId = objInstagramAccount.InstagramId;
                    grpProfile.ProfileType = "instagram";
                    grpProfile.ProfileName = objInstagramAccount.InsUserName;
                    grpProfile.ProfilePic = objInstagramAccount.ProfileUrl;
                    grpProfileRepo.AddGroupProfile(grpProfile);




                    #endregion
                    #region SocialProfile
                    Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.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);

                GetInstagramUserDetails(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken);
                GetInstagramFollowing(objInstagramAccount.UserId.ToString(), objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1);
                GetInstagramFollower(objInstagramAccount.UserId.ToString(), objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1);
                GetInstagramPostLikes(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1);
                GetInstagramPostComments(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken);
                //GetInstagramUserPosts(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
            return ret;
        }
        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);

            }
        }
Exemple #30
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);
     }
 }
        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);
        }