Search code examples
spring-socialspring-social-linkedin

Searching LinkedIn profiles by name on Spring Social


Is it possible to search LinkedIn Profiles by name within your network using Spring Social?

I've seen the search option defined on profileOperations but there's nothing like that available on connectionOperations. I was thinking something along the line of retrieving all the connection ids and using that as a filter on a profile search.

But I couldn't find any documentation on how to use the search function and since the connectionOperations only retrieves full profiles that's a pretty expensive operation, in any case.

Any suggestions?


Solution

  • Yes. It is possible.

    You can use the search() method in org.springframework.social.linkedin.api.ProfileOperations

    LinkedInProfiles search(SearchParameters parameters)
    

    Set the firstName and/or lastName attributes in SearchParameters object.

    Sample code:

    SearchParameters searchParameters = new SearchParameters();
    searchParameters.setFirstName("first_name");
    searchParameters.setLastName("last_name");
    LinkedInProfiles profiles = linkedinApi.profileOperations().search(searchParameters);
    

    Hope this helps. Let me know if you have any further questions.

    Praveen