本文整理汇总了C#中GlobusLinkedinLib.Authentication.oAuthLinkedIn.APIWebRequestAccessToken方法的典型用法代码示例。如果您正苦于以下问题:C# oAuthLinkedIn.APIWebRequestAccessToken方法的具体用法?C# oAuthLinkedIn.APIWebRequestAccessToken怎么用?C# oAuthLinkedIn.APIWebRequestAccessToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GlobusLinkedinLib.Authentication.oAuthLinkedIn
的用法示例。
在下文中一共展示了oAuthLinkedIn.APIWebRequestAccessToken方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddLinkedInAccount
public IHttpActionResult AddLinkedInAccount(LinkedInManager LinkedInManager)
{
string ret = "";
string UserId = LinkedInManager.UserId;
oAuthLinkedIn _oauth = new oAuthLinkedIn();
LinkedInProfile objProfile = new LinkedInProfile();
Domain.Socioboard.Domain.GroupProfile grpProfile = new Domain.Socioboard.Domain.GroupProfile();
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('"');
#region Get linkedin Profile data from Api
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);
}
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
{
//.........这里部分代码省略.........
示例2: GetLinkedinCompanyPage
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");
}
}