我正在实现LinkedIn API阅读器,以获取用户的摘要和技能。OAuth2身份验证过程运行正常,但是当我尝试检索配置文件对象时,我陷入了困境:
public void OAuth2(string code, string state, string error, string error_description)
{
// create a configuration object
var config = new LinkedInApiConfiguration("api-key", "api-secret-code");
// get the APIs client
var api = new LinkedInApi(config);
if(!string.IsNullOrEmpty(error) || !string.IsNullOrEmpty(error_description))
{
// handle error and error_description
}
else
{
var redirectUrl = "http://mywebsite/LinkedIn/OAuth2";
var userToken = api.OAuth2.GetAccessToken(code, redirectUrl);
var user = new UserAuthorization(userToken.AccessToken);
var profile = api.Profiles.GetMyProfile(user); //Here I don't know what to pass as acceptLanguages and FieldSelector!!
}
}
没有给出与“ ProfilesApi.GetMyProfile(UserAuthorization,string [],FieldSelector)”的所需形式参数“ acceptLanguages”相对应的参数
我试图从Sparkle.LinkedIn Api项目中了解,但是没有文档。
我只想检索摘要和技能字段。
通过创建带有语言代码和FIeldSelector变量的简单数组来解决:
var acceptLanguages = new string[] { "it-IT","en-US", };
var fields = FieldSelector.For<Person>()
.WithId()
.WithFirstName()
.WithLastName()
.WithFormattedName()
.WithEmailAddress()
.WithHeadline()
.WithLocationName()
.WithLocationCountryCode()
.WithPictureUrl()
.WithPublicProfileUrl()
.WithSummary();
Person profile = api.Profiles.GetMyProfile(user,acceptLanguages,fields);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句