public IHttpActionResult GetLinkedinCompanyPage(LinkedInManager LinkedInManager) { string UserId = LinkedInManager.UserId; oAuthLinkedIn _oauth = new oAuthLinkedIn(); LinkedInProfile objProfile = new LinkedInProfile(); List <Helper.AddlinkedinCompanyPage> lstAddLinkedinPage = new List <Helper.AddlinkedinCompanyPage>(); try { _oauth.ConsumerKey = ConfigurationManager.AppSettings["LinkedinApiKey"]; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.ConsumerSecret = ConfigurationManager.AppSettings["LinkedinSecretKey"]; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } string access_token_Url = "https://www.linkedin.com/uas/oauth2/accessToken"; string access_token_postData = "grant_type=authorization_code&code=" + LinkedInManager.Code + "&redirect_uri=" + System.Web.HttpUtility.UrlEncode(ConfigurationManager.AppSettings["LinkedinCallBackURL"]) + "&client_id=" + ConfigurationManager.AppSettings["LinkedinApiKey"] + "&client_secret=" + ConfigurationManager.AppSettings["LinkedinSecretKey"]; LinkedInProfile.UserProfile objUserProfile = new LinkedInProfile.UserProfile(); string token = _oauth.APIWebRequestAccessToken("POST", access_token_Url, access_token_postData); var oathtoken = JObject.Parse(token); _oauth.Token = oathtoken["access_token"].ToString().TrimStart('"').TrimEnd('"'); string response = _oauth.APIWebRequest("GET", GlobusLinkedinLib.App.Core.Global.GetLinkedInCompanyPageUrl, null); try { var companypage = JObject.Parse(response); foreach (var item in companypage["values"]) { Helper.AddlinkedinCompanyPage objAddLinkedinPage = new Helper.AddlinkedinCompanyPage(); objAddLinkedinPage.PageId = item["id"].ToString(); objAddLinkedinPage.PageName = item["name"].ToString(); objAddLinkedinPage._Oauth = _oauth; lstAddLinkedinPage.Add(objAddLinkedinPage); } string data = new JavaScriptSerializer().Serialize(lstAddLinkedinPage); return(Ok(data)); } catch (Exception) { return(Ok("No Company Page Found")); } }
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 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 IHttpActionResult GetLinkedinCompanyPage(LinkedInManager LinkedInManager) { string UserId = LinkedInManager.UserId; oAuthLinkedIn _oauth = new oAuthLinkedIn(); LinkedInProfile objProfile = new LinkedInProfile(); List<Helper.AddlinkedinCompanyPage> lstAddLinkedinPage = new List<Helper.AddlinkedinCompanyPage>(); try { _oauth.ConsumerKey = ConfigurationManager.AppSettings["LinkedinApiKey"]; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } try { _oauth.ConsumerSecret = ConfigurationManager.AppSettings["LinkedinSecretKey"]; } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error(ex.Message); } string access_token_Url = "https://www.linkedin.com/uas/oauth2/accessToken"; string access_token_postData = "grant_type=authorization_code&code=" + LinkedInManager.Code + "&redirect_uri=" + System.Web.HttpUtility.UrlEncode(ConfigurationManager.AppSettings["LinkedinCallBackURL"]) + "&client_id=" + ConfigurationManager.AppSettings["LinkedinApiKey"] + "&client_secret=" + ConfigurationManager.AppSettings["LinkedinSecretKey"]; LinkedInProfile.UserProfile objUserProfile = new LinkedInProfile.UserProfile(); string token = _oauth.APIWebRequestAccessToken("POST", access_token_Url, access_token_postData); var oathtoken = JObject.Parse(token); _oauth.Token = oathtoken["access_token"].ToString().TrimStart('"').TrimEnd('"'); string response = _oauth.APIWebRequest("GET", GlobusLinkedinLib.App.Core.Global.GetLinkedInCompanyPageUrl, null); try { var companypage = JObject.Parse(response); foreach (var item in companypage["values"]) { Helper.AddlinkedinCompanyPage objAddLinkedinPage = new Helper.AddlinkedinCompanyPage(); objAddLinkedinPage.PageId = item["id"].ToString(); objAddLinkedinPage.PageName = item["name"].ToString(); objAddLinkedinPage._Oauth = _oauth; lstAddLinkedinPage.Add(objAddLinkedinPage); } string data = new JavaScriptSerializer().Serialize(lstAddLinkedinPage); return Ok(data); } catch (Exception) { return Ok("No Company Page Found"); } }