I just spent way too much time trying to figure out how to call the LinkedIn People Search API. I needed to simply use the LinkedIn API to find people in my network by their full name. The last thing I want to do is try to figure out how to get OAuth working when I have a thousand other things to do. I downloaded all the C# libraries I could find, but most required a bunch of setup or compiling or hacking that I don’t have time for. I then came across the Spring.net Social Extension for LinkedIn. I went over to the SpringSource LinkedIn GitHub page and found this sample. It looked pretty straight forward so I decided to go for it…and got it working in about 10 minutes.
Here’s what I did:
-
Created my LinkedIn app. https://www.linkedin.com/secure/developer?newapp=
-
Created a new C# project and referenced Spring.Social.LinkedIn via nuGet
- Referenced Common.Logging (I actually did this later because I was getting an exception, but just do it now)
- Copied the 4 following strings into my project:
private const string LinkedInApiKey = "[copy from your linked in app details page]";
private const string LinkedInApiSecret = "[copy from your linked in app details page]";
private const string LinkedInUserToken = "[copy from your linked in app details page]";
private const string LinkedInUserSecret = "[copy from your linked in app details page]";
- Created this SearchAsync method
public async Task<LinkedInProfiles> SearchAsync(string queryText)
{
var l = new LinkedInServiceProvider(LinkedInApiKey, LinkedInApiSecret);
var a = l.GetApi(LinkedInUserToken, LinkedInUserSecret);
var sp = new SearchParameters() { Keywords = queryText };
return await a.ProfileOperations.SearchAsync(sp);
}
6. Called SearchAsync method from another method
var p = SearchAsync(queryText);
foreach (LinkedInProfile pr in p.Result.Profiles){}
I hope this saves you some time.
Jon