Connect with LinkedIn in java


We needed to post LinkedIn updates in our gwt based application. LinkedIn-J is a java wrapper over LinkedIn API’s. We used this to post LinkedIn updates in our application.
We have also used signpost-core. It stands for simple oauth messages signing for java.
It exoposes a simple interface to sign HTTP requests using a given OAuth token and secret.

For getting this work we downloaded linkedin-j and signpost-core from the following location.
You can paste this jar in lib directory of your java based GWT application. Now our project is ready for using linkedin-j libraries.

Now the next step for calling any API method is to create the API client using the api key, api secret, access token, token secret.

final LinkedInApiClientFactory factory = LinkedInApiClientFactory.newInstance("consumer_key","consumer_secret");

final LinkedInApiClient client = factory.createLinkedInApiClient("access_key","access_token");

Thats it! now you can interact with linkedin.

All the methods in the library are divided into these categories.

1.To send updates on linkedIn profiles.

client.updateCurrentStatus("Your status");

2.Profile API
To fetch the profile of a person by ID.

Person profile = client.getProfileById(id);

System.out.println("Name:" + profile.getFirstName() + " " + profile.getLastName());
System.out.println("Headline:" + profile.getHeadline());
System.out.println("Summary:" + profile.getSummary());
System.out.println("Industry:" + profile.getIndustry());
System.out.println("Picture:" + profile.getPictureUrl());

3.Connections API
To get connections of the current user:

Connections connections = client.getConnectionsForCurrentUser();
System.out.println("Total connections fetched:" + connections.getTotal());

4.Network Updates API
To fetch network updates of the current user:

Network network = client.getNetworkUpdates(EnumSet.of(NetworkUpdateType.STATUS_UPDATE));
System.out.println("Total updates fetched:" + network.getUpdates().getTotal());
About these ads
This entry was posted in Java, Web and tagged . Bookmark the permalink.

4 Responses to Connect with LinkedIn in java

  1. santosh says:

    I could not find consumer key and consumer secret using linkedln app.please help

  2. tpp says:

    linkedin-j is not maintained. The author hasn’t updated it in months and it’s sorely lacking features available in updates to LinkedIn’s APIs.

  3. Ashis says:

    I got: {API Key, Secret Key, OAuth User Token, OAuth User Secret}, used them as {consumer_key, consumer_secret, access_key, access_token} not sure if this was correct but getting Error.

    Can any one guide what is the correct use of these two lines:
    factory = LinkedInApiClientFactory.newInstance(consumer_key, consumer_secret); // Correct ??
    client = factory.createLinkedInApiClient(OAuth_User_Token, OAuth_User_Secret);// Correct ??

  4. Kirti Hudda says:

    Can anyone please tell me the function to follow some one on linkedin in Linkedin-j api??

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s