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 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 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 static oAuthInstagram GetInstance() { if (_sharedInstance == null) { if (_sharedConfiguration == null) throw new ApplicationException("API Uninitialized"); else _sharedInstance = new oAuthInstagram(); } return _sharedInstance; }
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 static oAuthInstagram GetInstance() { if (_sharedInstance == null) { if (_sharedConfiguration == null) { throw new ApplicationException("API Uninitialized"); } else { _sharedInstance = new oAuthInstagram(); } } return(_sharedInstance); }
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 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 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); }
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 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); }
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); #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; }