public string GetLinkedinCompanyPage(string oauth_token, string oauth_verifier, string reuqestTokenSecret, string consumerKey, string consumerSecret, string UserId, string GroupId) { List<Helper.AddlinkedinCompanyPage> lstAddLinkedinPage = new List<Helper.AddlinkedinCompanyPage>(); string ret = string.Empty; oAuthLinkedIn _oauth = new oAuthLinkedIn(); try { _oauth.ConsumerKey = consumerKey; } catch (Exception ex) { Console.WriteLine(ex.Message); } try { _oauth.ConsumerSecret = consumerSecret; } catch (Exception ex) { Console.WriteLine(ex.Message); } try { _oauth.Token = oauth_token; } catch (Exception ex) { Console.WriteLine(ex.Message); } try { _oauth.TokenSecret = reuqestTokenSecret; } catch (Exception ex) { Console.WriteLine(ex.Message); } try { _oauth.Verifier = oauth_verifier; } catch (Exception ex) { Console.WriteLine(ex.Message); } try { _oauth.AccessTokenGet(oauth_token); } catch (Exception ex) { Console.WriteLine(ex.Message); } XmlDocument xmlResult = new XmlDocument(); XmlDocument xmlCompany = new XmlDocument(); GlobusLinkedinLib.LinkedIn.Core.PeopleMethods.People peopleConnection = new GlobusLinkedinLib.LinkedIn.Core.PeopleMethods.People(); xmlResult = peopleConnection.Get_UserProfile(_oauth); string UserProfileId = xmlResult.GetElementsByTagName("id")[0].InnerText; string response = _oauth.APIWebRequest("GET", GlobusLinkedinLib.App.Core.Global.GetCompanyUrl, null); string strLidPageDiv = string.Empty; xmlCompany.Load(new StringReader(response)); string cnt = string.Empty; XmlElement root = xmlCompany.DocumentElement; if (root.HasAttribute("total")) { cnt = root.GetAttribute("total"); } int total = Convert.ToInt16(cnt); if (total != 0) { for (int i = 0; i < total; i++) { Helper.AddlinkedinCompanyPage objAddLinkedinPage = new Helper.AddlinkedinCompanyPage(); objAddLinkedinPage.PageId = xmlCompany.GetElementsByTagName("id")[i].InnerText; objAddLinkedinPage.PageName = xmlCompany.GetElementsByTagName("name")[i].InnerText; objAddLinkedinPage._Oauth = _oauth; lstAddLinkedinPage.Add(objAddLinkedinPage); } } return new JavaScriptSerializer().Serialize(lstAddLinkedinPage); }
public string AddLinkedinAccount(string oauth_token, string oauth_verifier, string reuqestTokenSecret, string consumerKey, string consumerSecret, string UserId, string GroupId) { try { logger.Error("AddLinkedinAccount()"); System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls; string ret = string.Empty; LinkedInProfile objProfile = new LinkedInProfile(); LinkedInProfile.UserProfile objUserProfile = new LinkedInProfile.UserProfile(); objSocialProfile = new Domain.Socioboard.Domain.SocialProfile(); oAuthLinkedIn _oauth = new oAuthLinkedIn(); objLinkedInAccount = new LinkedInAccount(); #region Get linkedin Profile data from Api try { _oauth.ConsumerKey = consumerKey; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.ConsumerSecret = consumerSecret; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.Token = oauth_token; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.TokenSecret = reuqestTokenSecret; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.Verifier = oauth_verifier; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.AccessTokenGet(oauth_token); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { objUserProfile = objProfile.GetUserProfile(_oauth); } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } #endregion dynamic data = objUserProfile; try { #region LinkedInAccount objLinkedInAccount.UserId = Guid.Parse(UserId); objLinkedInAccount.LinkedinUserId = data.id.ToString(); try { objLinkedInAccount.EmailId = data.email.ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); } objLinkedInAccount.LinkedinUserName = data.first_name.ToString() + data.last_name.ToString(); objLinkedInAccount.OAuthToken = _oauth.Token; objLinkedInAccount.OAuthSecret = _oauth.TokenSecret; objLinkedInAccount.OAuthVerifier = _oauth.Verifier; try { objLinkedInAccount.ProfileImageUrl = data.picture_url.ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); } try { objLinkedInAccount.ProfileUrl = data.profile_url.ToString(); } catch (Exception ex) { logger.Error(ex.StackTrace); } #endregion #region SocialProfiles try { objLinkedInAccount.Connections = data.connections; objLinkedInAccount.IsActive = true; objSocialProfile.UserId = Guid.Parse(UserId); objSocialProfile.ProfileType = "linkedin"; objSocialProfile.ProfileId = data.id.ToString(); objSocialProfile.ProfileStatus = 1; objSocialProfile.ProfileDate = DateTime.Now; objSocialProfile.Id = Guid.NewGuid(); } catch (Exception ex) { logger.Error(ex.Message); } #endregion SocialProfiles #region Add TeamMemberProfile try { Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId)); objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile(); objTeamMemberProfile.Id = Guid.NewGuid(); objTeamMemberProfile.TeamId = objTeam.Id; objTeamMemberProfile.Status = 1; objTeamMemberProfile.ProfileType = "linkedin"; objTeamMemberProfile.StatusUpdateDate = DateTime.Now; objTeamMemberProfile.ProfileId = objLinkedInAccount.LinkedinUserId; objTeamMemberProfile.ProfileName = objLinkedInAccount.LinkedinUserName; objTeamMemberProfile.ProfilePicUrl = objLinkedInAccount.ProfileImageUrl; } catch (Exception ex) { logger.Error(ex.Message); } #endregion } catch (Exception ex) { logger.Error(ex.StackTrace); } try { if (!objLinkedInAccountRepository.checkLinkedinUserExists(objLinkedInAccount.LinkedinUserId, Guid.Parse(UserId))) { objLinkedInAccountRepository.addLinkedinUser(objLinkedInAccount); ret = "LinkedIn Account Added Successfully"; } else { ret = "LinkedIn Account Already Exist"; } if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile)) { objSocialProfilesRepository.addNewProfileForUser(objSocialProfile); } if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objLinkedInAccount.LinkedinUserId)) { objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile); } #region Add LinkedIn Feeds LinkedInNetwork objln = new LinkedInNetwork(); List<LinkedInNetwork.Network_Updates> userUPdate = objln.GetNetworkUpdates(_oauth, 20); foreach (var item in userUPdate) { try { objLinkedInFeed = new Domain.Socioboard.Domain.LinkedInFeed(); objLinkedInFeed.Feeds = item.Message; objLinkedInFeed.FromId = item.PersonId; objLinkedInFeed.FromName = item.PersonFirstName + " " + item.PersonLastName; objLinkedInFeed.FeedsDate = Convert.ToDateTime(item.DateTime); objLinkedInFeed.EntryDate = DateTime.Now; objLinkedInFeed.ProfileId = objLinkedInAccount.LinkedinUserId; objLinkedInFeed.Type = item.UpdateType; objLinkedInFeed.UserId = Guid.Parse(UserId); objLinkedInFeed.FromPicUrl = item.PictureUrl; objLinkedInFeed.ImageUrl = item.ImageUrl; objLinkedInFeed.FromUrl = item.url; } catch (Exception ex) { logger.Error(ex.StackTrace); } if (!objLinkedInFeedRepository.checkLinkedInFeedExists(objLinkedInFeed.FeedId, Guid.Parse(UserId))) { objLinkedInFeedRepository.addLinkedInFeed(objLinkedInFeed); } } #endregion #region Add LinkedIn UserUpdates GlobusLinkedinLib.App.Core.LinkedInUser l = new GlobusLinkedinLib.App.Core.LinkedInUser(); List<Domain.Socioboard.Domain.LinkedIn_Update_Messages> lst_Messages = l.GetUserUpdateNew(_oauth, objLinkedInAccount.LinkedinUserId, 10); foreach (var item_Messages in lst_Messages) { try { objLinkedInMessage = new Domain.Socioboard.Domain.LinkedInMessage(); objLinkedInMessage.Id = Guid.NewGuid(); objLinkedInMessage.Message = item_Messages.Message; objLinkedInMessage.ProfileId = item_Messages.ProfileId; objLinkedInMessage.ProfileName = item_Messages.ProfileName; objLinkedInMessage.CreatedDate = Convert.ToDateTime(item_Messages.CreatedDate); objLinkedInMessage.EntryDate = DateTime.Now; objLinkedInMessage.Type = item_Messages.Type; objLinkedInMessage.UserId = Guid.Parse(UserId); objLinkedInMessage.ImageUrl = item_Messages.ImageUrl; objLinkedInMessage.FeedId = item_Messages.FeedId; objLinkedInMessage.ProfileUrl = item_Messages.ProfileUrl; objLinkedInMessage.Comments = item_Messages.Comments; objLinkedInMessage.Likes = item_Messages.Likes; objLinkedInMessage.ProfileImageUrl = item_Messages.ProfileImageUrl; } catch (Exception ex) { logger.Error(ex.StackTrace); } if (!objLinkedInMessageRepository.checkLinkedInMessageExists(objLinkedInAccount.LinkedinUserId, objLinkedInMessage.FeedId, Guid.Parse(UserId))) { objLinkedInMessageRepository.addLinkedInMessage(objLinkedInMessage); } } #endregion } catch (Exception ex) { logger.Error(ex.StackTrace); } return ""; } catch (Exception ex) { logger.Error(ex.StackTrace); return ""; } }
public string LinkedinCompnayJobs(string CompanyId) { string response = string.Empty; try { //ArrayList alstLIAccounts = objLinkedinrepo.getAllLinkedinAccounts(); //Domain.Socioboard.Domain.LinkedInAccount linkacc = (Domain.Socioboard.Domain.LinkedInAccount)alstLIAccounts[0]; oAuthLinkedIn oauth = new oAuthLinkedIn(); oauth.ConsumerKey = ConfigurationManager.AppSettings["LiApiKey"]; oauth.ConsumerSecret = ConfigurationManager.AppSettings["LiSecretKey"]; oauth.Token = "49c2202b-2cd4-4c74-b5db-ce8d7f5e029e"; oauth.TokenSecret = "a79cfbe5-d268-456e-8fdc-0d12869a1cf3"; oauth.Verifier = "52921"; //oauth.AccessTokenGet(linkacc.OAuthToken); oauth.AccessTokenGet("fd200850-37b4-4845-9671-13e5280c7535"); //TODO : access Token Logic //oauth.AccessTokenGet(); //https://api.linkedin.com/v1/people-search? keywords=[space delimited keywords] //oauth.AccessTokenGet(oauth.Token); // company.Get_CompanyProfileById(oauth, keyword); //string response = oauth.APIWebRequest("GET", "https://api.linkedin.com/v1/companies/" + keyword + ":(id,name,email-domains,description,founded-year,end-year,locations,Specialties,website-url,status,employee-count-range,industries,company-type,logo-url,square-logo-url,blog-rss-url,num-followers,universal-name)", null); response = oauth.APIWebRequest("GET", "https://api.linkedin.com/v1/jobs/" + CompanyId, null); } catch (Exception e) { } return response; }
public string LinkedinCompanyrecentActivites(string CompanyId) { string response = string.Empty; try { //ArrayList alstLIAccounts = objLinkedinrepo.getAllLinkedinAccounts(); //Domain.Socioboard.Domain.LinkedInAccount linkacc = (Domain.Socioboard.Domain.LinkedInAccount)alstLIAccounts[0]; oAuthLinkedIn oauth = new oAuthLinkedIn(); oauth.ConsumerKey = ConfigurationManager.AppSettings["LiApiKey"]; oauth.ConsumerSecret = ConfigurationManager.AppSettings["LiSecretKey"]; //oauth.Token = "49c2202b-2cd4-4c74-b5db-ce8d7f5e029e"; //oauth.TokenSecret = "a79cfbe5-d268-456e-8fdc-0d12869a1cf3"; //oauth.Verifier = "52921"; oauth.Token = "b82db6bb-21bb-44d2-a298-0b093708ddbf"; oauth.TokenSecret = "f7c9b7b8-9295-46fe-8cb4-914c1c52820f"; oauth.Verifier = "23836"; //oauth.AccessTokenGet(linkacc.OAuthToken); //TODO: access Token Logic oauth.AccessTokenGet("b82db6bb-21bb-44d2-a298-0b093708ddbf"); //https://api.linkedin.com/v1/people-search? keywords=[space delimited keywords] //oauth.AccessTokenGet(oauth.Token); // company.Get_CompanyProfileById(oauth, keyword); //string response = oauth.APIWebRequest("GET", "https://api.linkedin.com/v1/companies/" + keyword + ":(id,name,email-domains,description,founded-year,end-year,locations,Specialties,website-url,status,employee-count-range,industries,company-type,logo-url,square-logo-url,blog-rss-url,num-followers,universal-name)", null); response = oauth.APIWebRequest("GET", "https://api.linkedin.com/v1/companies/" + CompanyId + "/updates?start=0&count=200&event-type=status-update", null); } catch (Exception e) { } return response; }
public string LinkedinSearch(string keyword) { string profileid = string.Empty; try { // ArrayList alstLIAccounts = objLinkedinrepo.getAllLinkedinAccounts(); //Domain.Socioboard.Domain.LinkedInAccount linkacc = (Domain.Socioboard.Domain.LinkedInAccount)alstLIAccounts[0]; oAuthLinkedIn oauth = new oAuthLinkedIn(); oauth.ConsumerKey = ConfigurationManager.AppSettings["LiApiKey"]; oauth.ConsumerSecret = ConfigurationManager.AppSettings["LiSecretKey"]; //oauth.Token = "49c2202b-2cd4-4c74-b5db-ce8d7f5e029e"; //oauth.TokenSecret = "a79cfbe5-d268-456e-8fdc-0d12869a1cf3"; //oauth.Verifier = "52921"; oauth.Token = "b82db6bb-21bb-44d2-a298-0b093708ddbf"; oauth.TokenSecret = "f7c9b7b8-9295-46fe-8cb4-914c1c52820f"; oauth.Verifier = "23836"; //oauth.AccessTokenGet(linkacc.OAuthToken); //TODO: access Token Logic oauth.AccessTokenGet("b82db6bb-21bb-44d2-a298-0b093708ddbf"); //oauth.AccessTokenGet(); //https://api.linkedin.com/v1/people-search? keywords=[space delimited keywords] //oauth.AccessTokenGet(oauth.Token); // company.Get_CompanyProfileById(oauth, keyword); //string response = oauth.APIWebRequest("GET", "https://api.linkedin.com/v1/companies/" + keyword + ":(id,name,email-domains,description,founded-year,end-year,locations,Specialties,website-url,status,employee-count-range,industries,company-type,logo-url,square-logo-url,blog-rss-url,num-followers,universal-name)", null); string response = oauth.APIWebRequest("GET", "https://api.linkedin.com/v1/company-search" + ":(companies:(id,name,universal-name,website-url,industries,status,logo-url,blog-rss-url,twitter-id,employee-count-range,specialties,locations,description,stock-exchange,founded-year,end-year,num-followers))?keywords=" + keyword, null); XmlDocument XmlResult = new XmlDocument(); XmlResult.Load(new StringReader(response)); XmlNode ResultCompany = null; int followers = 0; string result = string.Empty; XmlNodeList Companies = XmlResult.SelectNodes("company-search/companies/company"); foreach (XmlNode node in Companies) { if (Convert.ToInt32(node.SelectSingleNode("num-followers").InnerText) > followers) { ResultCompany = node; followers = Convert.ToInt32(node.SelectSingleNode("num-followers").InnerText); } } return response; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return new JavaScriptSerializer().Serialize("Please try Again"); } }
public string LinkedinCompnayJobs(string CompanyId) { string response = string.Empty; try { ArrayList alstLIAccounts = objLinkedinrepo.getAllLinkedinAccounts(); Domain.Socioboard.Domain.LinkedInAccount linkacc = (Domain.Socioboard.Domain.LinkedInAccount)alstLIAccounts[0]; oAuthLinkedIn oauth = new oAuthLinkedIn(); oauth.ConsumerKey = ConfigurationManager.AppSettings["LiApiKey"]; oauth.ConsumerSecret = ConfigurationManager.AppSettings["LiSecretKey"]; oauth.Token = "Token"; oauth.TokenSecret = "Your Token Secret"; oauth.Verifier = "Your verifier"; oauth.AccessTokenGet(linkacc.OAuthToken); //oauth.AccessTokenGet(); //https://api.linkedin.com/v1/people-search? keywords=[space delimited keywords] //oauth.AccessTokenGet(oauth.Token); // company.Get_CompanyProfileById(oauth, keyword); //string response = oauth.APIWebRequest("GET", "https://api.linkedin.com/v1/companies/" + keyword + ":(id,name,email-domains,description,founded-year,end-year,locations,Specialties,website-url,status,employee-count-range,industries,company-type,logo-url,square-logo-url,blog-rss-url,num-followers,universal-name)", null); response = oauth.APIWebRequest("GET", "https://api.linkedin.com/v1/jobs/" + CompanyId, null); } catch (Exception e) { } return response; }