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); }
protected void btnSave_Click(object sender, EventArgs e) { try { bool status = false; string type = Request.QueryString["type"].ToString(); if (Session["updateData"] != null) { if (type == "twt") { TwitterAccount twtAcc = (TwitterAccount)Session["updateData"]; //if (ddltatus.SelectedValue == "1") status = true; twtAcc.TwitterScreenName = txtName.Text; twtAcc.IsActive = status; objTwtRepo.updateTwitterUser(twtAcc); } if (type == "fb") { FacebookAccount fbAcc = (FacebookAccount)Session["updateData"]; // if (ddltatus.SelectedValue == "1") FBAcc.FbUserName = txtName.Text; status = true; fbAcc.IsActive = 1; objFbRepo.updateFacebookUser(fbAcc); } if (type == "ins") { InstagramAccount insAcc = (InstagramAccount)Session["updateData"]; //if (ddltatus.SelectedValue == "1") InsAcc.InsUserName = txtName.Text; status = true; insAcc.IsActive = status; objInsRepo.updateInstagramUser(insAcc); } if (type == "li") { LinkedInAccount liAcc = (LinkedInAccount)Session["updateData"]; // if (ddltatus.SelectedValue == "1") liAcc.LinkedinUserName = txtName.Text; status = true; liAcc.IsActive = status; objLiRepo.updateLinkedinUser(liAcc); } if (type == "gp") { GooglePlusAccount gpAcc = (GooglePlusAccount)Session["updateData"]; // gpAcc.IsActive = int.Parse(ddltatus.SelectedValue); GpAcc.GpUserName = txtName.Text; gpAcc.IsActive = 1; objgpRepo.updateGooglePlusUser(gpAcc); } } } catch (Exception Err) { logger.Error(Err.Message); Response.Write(Err.StackTrace); } }