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.

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 )

Connecting to %s