【发布时间】:2017-12-16 20:21:12
【问题描述】:
我正在尝试使用 Sparkle.LinkedIn 从 LinkedIn API 获取摘要和技能字段。 一切正常,我可以阅读 Headline、FirstName 和 LastName 字段,但 Skills、Summary、Industry、DateOfBirth和其他字段总是为空,即使 LinkedIn 个人资料肯定有这些字段。
这是我在用户已经通过身份验证并且我拥有令牌时使用的代码:
var fields = FieldSelector.For<Person>()
.WithId()
.WithFirstName()
.WithLastName()
.WithEmailAddress()
.WithHeadline()
.WithPictureUrl()
.WithPublicProfileUrl()
.WithSummary()
.WithIndustry()
.WithDateOfBirth()
.WithSkills();
var config = new LinkedInApiConfiguration("api-key", "key-secret");
var api = new LinkedInApi(config);
if(!string.IsNullOrEmpty(error) || !string.IsNullOrEmpty(error_description))
{
Response.Write(error + "<br/>" + error_description);
}
else
{
var redirectUrl = "my-redirect-url";
var userToken = api.OAuth2.GetAccessToken(code, redirectUrl);
var acceptLanguages = new string[] { "it-IT","en-US", };
var user = new UserAuthorization(userToken.AccessToken);
Person profile = api.Profiles.GetMyProfile(user,acceptLanguages,fields);
Response.Write(profile.Headline + "<br/>");
Response.Write(profile.Summary + "<br/>"); //always empty
Response.Write(profile.Industry + "<br/>"); //always empty
Response.Write(profile.PictureUrl + "<br/>"); //always empty
if(profile.Skills!=null) //always null
{
foreach (var sk in profile.Skills.Skill)
{
Response.Write(sk.SkillName.Name + "<br/>");
}
}
Response.Write(profile.Lastname + "<br/>");
Response.Write(profile.DateOfBirth.Year + "<br/>"); //always empty
}
如何同时检索摘要和技能字段?
【问题讨论】:
-
代码看起来不错。这似乎是 LinkedIn 的一个细微差别,也许是 Achille 所暗示的授权。
-
在 Internet 中搜索似乎在 Linked API 中有一个未记录的重大变化,因为他们正在关闭对开放 API 的大多数字段的访问。只有LinkedIn的大公司合作伙伴可以访问它。这是我读到的,如果有人可以确认的话,