使用Sparkle.LinkedInNET的LinkedIn API v2:检索摘要和技能

问题描述 投票:1回答:1

我正在实现一个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项目中理解,但没有文档。

我想只检索摘要和技能字段。

c# api linkedin
1个回答
1
投票

通过创建一个包含语言代码的简单数组和一个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);
© www.soinside.com 2019 - 2024. All rights reserved.