Chapter 202. Linkedin Component
Available as of Camel version 2.14
The LinkedIn component provides access to all of LinkedIn REST APIs documented at https://developer.linkedin.com/rest[https://developer.linkedin.com/rest].
LinkedIn uses OAuth2.0 for all client application authentication. In order to use camel-linkedin with your account, you’ll need to create a new application for LinkedIn at https://www.linkedin.com/secure/developer. The LinkedIn application’s client id and secret will allow access to LinkedIn REST APIs which require a current user. A user access token is generated and managed by component for an end user. Alternatively the Camel application can register an implementation of org.apache.camel.component.linkedin.api.OAuthSecureStorage to provide an org.apache.camel.component.linkedin.apiOAuthToken OAuth token.
Maven users will need to add the following dependency to their pom.xml for this component:
<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-linkedin</artifactId> <version>${camel-version}</version> </dependency>
202.1. URI format
linkedin://endpoint-prefix/endpoint?[options]
Endpoint prefix can be one of:
- comments
- companies
- groups
- jobs
- people
- posts
- search
202.2. LinkedInComponent
The Linkedin component supports 2 options which are listed below.
Name | Description | Default | Type |
---|---|---|---|
configuration (common) | To use the shared configuration | LinkedInConfiguration | |
resolveProperty Placeholders (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean |
The Linkedin endpoint is configured using URI syntax:
linkedin:apiName/methodName
with the following path and query parameters:
202.2.1. Path Parameters (2 parameters):
Name | Description | Default | Type |
---|---|---|---|
apiName | Required What kind of operation to perform | LinkedInApiName | |
methodName | Required What sub operation to use for the selected operation | String |
202.2.2. Query Parameters (14 parameters):
Name | Description | Default | Type |
---|---|---|---|
clientId (common) | LinkedIn application client ID | String | |
clientSecret (common) | LinkedIn application client secret | String | |
httpParams (common) | Custom HTTP params, for example proxy host and port, use constants from AllClientPNames | Map | |
inBody (common) | Sets the name of a parameter to be passed in the exchange In Body | String | |
lazyAuth (common) | Flag to enable/disable lazy OAuth, default is true. when enabled, OAuth token retrieval or generation is not done until the first REST call | true | boolean |
redirectUri (common) | Application redirect URI, although the component never redirects to this page to avoid having to have a functioning redirect server. So for testing one could use https://localhost | String | |
scopes (common) | List of LinkedIn scopes as specified at https://developer.linkedin.com/documents/authenticationgranting | OAuthScope[] | |
secureStorage (common) | Callback interface for providing an OAuth token or to store the token generated by the component. The callback should return null on the first call and then save the created token in the saveToken() callback. If the callback returns null the first time, a userPassword MUST be provided | OAuthSecureStorage | |
userName (common) | LinkedIn user account name, MUST be provided | String | |
userPassword (common) | LinkedIn account password | String | |
bridgeErrorHandler (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean |
exceptionHandler (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | ExceptionHandler | |
exchangePattern (consumer) | Sets the exchange pattern when the consumer creates an exchange. | ExchangePattern | |
synchronous (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean |
202.3. Producer Endpoints:
Producer endpoints can use endpoint prefixes followed by endpoint names and associated options described next. A shorthand alias can be used for some endpoints. The endpoint URI MUST contain a prefix.
Endpoint options that are not mandatory are denoted by []. When there are no mandatory options for an endpoint, one of the set of [] options MUST be provided. Producer endpoints can also use a special option inBody that in turn should contain the name of the endpoint option whose value will be contained in the Camel Exchange In message.
Any of the endpoint options can be provided in either the endpoint URI, or dynamically in a message header. The message header name must be of the format CamelLinkedIn.<option>. Note that the inBody option overrides message header, i.e. the endpoint option inBody=option would override a CamelLinkedIn.option header.
For more information on the endpoints and options see LinkedIn REST API documentation at https://developer.linkedin.com/rest[https://developer.linkedin.com/rest].
202.3.1. Endpoint prefix comments
The following endpoints can be invoked with the prefix comments as follows:
linkedin://comments/endpoint?[options]
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
getComment | comment | comment_id, fields | org.apache.camel.component.linkedin.api.model.Comment |
removeComment | comment | comment_id |
URI Options for comments
Name | Type |
---|---|
comment_id | String |
fields | String |
202.3.2. Endpoint prefix companies
The following endpoints can be invoked with the prefix companies as follows:
linkedin://companies/endpoint?[options]
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
addCompanyUpdateComment | companyUpdateComment | company_id, update_key, updatecomment | |
addCompanyUpdateCommentAsCompany | companyUpdateCommentAsCompany | company_id, update_key, updatecomment | |
addShare | share | company_id, share | |
getCompanies | companies | email_domain, fields, is_company_admin | org.apache.camel.component.linkedin.api.model.Companies |
getCompanyById | companyById | company_id, fields | org.apache.camel.component.linkedin.api.model.Company |
getCompanyByName | companyByName | fields, universal_name | org.apache.camel.component.linkedin.api.model.Company |
getCompanyUpdateComments | companyUpdateComments | company_id, fields, secure_urls, update_key | org.apache.camel.component.linkedin.api.model.Comments |
getCompanyUpdateLikes | companyUpdateLikes | company_id, fields, secure_urls, update_key | org.apache.camel.component.linkedin.api.model.Likes |
getCompanyUpdates | companyUpdates | company_id, count, event_type, fields, start | org.apache.camel.component.linkedin.api.model.Updates |
getHistoricalFollowStatistics | historicalFollowStatistics | company_id, end_timestamp, start_timestamp, time_granularity | org.apache.camel.component.linkedin.api.model.HistoricalFollowStatistics |
getHistoricalStatusUpdateStatistics | historicalStatusUpdateStatistics | company_id, end_timestamp, start_timestamp, time_granularity, update_key | org.apache.camel.component.linkedin.api.model.HistoricalStatusUpdateStatistics |
getNumberOfFollowers | numberOfFollowers | companySizes, company_id, geos, industries, jobFunc, seniorities | org.apache.camel.component.linkedin.api.model.NumFollowers |
getStatistics | statistics | company_id | org.apache.camel.component.linkedin.api.model.CompanyStatistics |
isShareEnabled | company_id | org.apache.camel.component.linkedin.api.model.IsCompanyShareEnabled | |
isViewerShareEnabled | company_id | org.apache.camel.component.linkedin.api.model.IsCompanyShareEnabled | |
likeCompanyUpdate | company_id, isliked, update_key |
URI Options for companies
If a value is not provided for one of the option(s) [companySizes, count, email_domain, end_timestamp, event_type, geos, industries, is_company_admin, jobFunc, secure_urls, seniorities, start, start_timestamp, time_granularity] either in the endpoint URI or in a message header, it will be assumed to be null. Note that the null value(s) will only be used if other options do not satisfy matching endpoints.
Name | Type |
---|---|
companySizes | java.util.List |
company_id | Long |
count | Long |
email_domain | String |
end_timestamp | Long |
event_type | org.apache.camel.component.linkedin.api.Eventtype |
fields | String |
geos | java.util.List |
industries | java.util.List |
is_company_admin | Boolean |
isliked | org.apache.camel.component.linkedin.api.model.IsLiked |
jobFunc | java.util.List |
secure_urls | Boolean |
seniorities | java.util.List |
share | org.apache.camel.component.linkedin.api.model.Share |
start | Long |
start_timestamp | Long |
time_granularity | org.apache.camel.component.linkedin.api.Timegranularity |
universal_name | String |
update_key | String |
updatecomment | org.apache.camel.component.linkedin.api.model.UpdateComment |
202.3.3. Endpoint prefix groups
The following endpoints can be invoked with the prefix groups as follows:
linkedin://groups/endpoint?[options]
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
addPost | post | group_id, post | |
getGroup | group | group_id | org.apache.camel.component.linkedin.api.model.Group |
URI Options for groups
Name | Type |
---|---|
group_id | Long |
post | org.apache.camel.component.linkedin.api.model.Post |
202.3.4. Endpoint prefix jobs
The following endpoints can be invoked with the prefix jobs as follows:
linkedin://jobs/endpoint?[options]
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
addJob | job | job | |
editJob | job, partner_job_id | ||
getJob | job | fields, job_id | org.apache.camel.component.linkedin.api.model.Job |
URI Options for jobs
Name | Type |
---|---|
fields | String |
job | org.apache.camel.component.linkedin.api.model.Job |
job_id | Long |
partner_job_id | Long |
202.3.5. Endpoint prefix people
The following endpoints can be invoked with the prefix people as follows:
linkedin://people/endpoint?[options]
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
addActivity | activity | activity | |
addGroupMembership | groupMembership | groupmembership | |
addInvite | invite | mailboxitem | |
addJobBookmark | jobBookmark | jobbookmark | |
addUpdateComment | updateComment | update_key, updatecomment | |
followCompany | company | ||
getConnections | connections | fields, secure_urls | org.apache.camel.component.linkedin.api.model.Connections |
getConnectionsById | connectionsById | fields, person_id, secure_urls | org.apache.camel.component.linkedin.api.model.Connections |
getConnectionsByUrl | connectionsByUrl | fields, public_profile_url, secure_urls | org.apache.camel.component.linkedin.api.model.Connections |
getFollowedCompanies | followedCompanies | fields | org.apache.camel.component.linkedin.api.model.Companies |
getGroupMembershipSettings | groupMembershipSettings | count, fields, group_id, start | org.apache.camel.component.linkedin.api.model.GroupMemberships |
getGroupMemberships | groupMemberships | count, fields, membership_state, start | org.apache.camel.component.linkedin.api.model.GroupMemberships |
getJobBookmarks | jobBookmarks | org.apache.camel.component.linkedin.api.model.JobBookmarks | |
getNetworkStats | networkStats | org.apache.camel.component.linkedin.api.model.NetworkStats | |
getNetworkUpdates | networkUpdates | after, before, count, fields, scope, secure_urls, show_hidden_members, start, type | org.apache.camel.component.linkedin.api.model.Updates |
getNetworkUpdatesById | networkUpdatesById | after, before, count, fields, person_id, scope, secure_urls, show_hidden_members, start, type | org.apache.camel.component.linkedin.api.model.Updates |
getPerson | person | fields, secure_urls | org.apache.camel.component.linkedin.api.model.Person |
getPersonById | personById | fields, person_id, secure_urls | org.apache.camel.component.linkedin.api.model.Person |
getPersonByUrl | personByUrl | fields, public_profile_url, secure_urls | org.apache.camel.component.linkedin.api.model.Person |
getPosts | posts | category, count, fields, group_id, modified_since, order, role, start | org.apache.camel.component.linkedin.api.model.Posts |
getSuggestedCompanies | suggestedCompanies | fields | org.apache.camel.component.linkedin.api.model.Companies |
getSuggestedGroupPosts | suggestedGroupPosts | category, count, fields, group_id, modified_since, order, role, start | org.apache.camel.component.linkedin.api.model.Posts |
getSuggestedGroups | suggestedGroups | fields | org.apache.camel.component.linkedin.api.model.Groups |
getSuggestedJobs | suggestedJobs | fields | org.apache.camel.component.linkedin.api.model.JobSuggestions |
getUpdateComments | updateComments | fields, secure_urls, update_key | org.apache.camel.component.linkedin.api.model.Comments |
getUpdateLikes | updateLikes | fields, secure_urls, update_key | org.apache.camel.component.linkedin.api.model.Likes |
likeUpdate | isliked, update_key | ||
removeGroupMembership | groupMembership | group_id | |
removeGroupSuggestion | groupSuggestion | group_id | |
removeJobBookmark | jobBookmark | job_id | |
share | share | org.apache.camel.component.linkedin.api.model.Update | |
stopFollowingCompany | company_id | ||
updateGroupMembership | group_id, groupmembership |
URI Options for people
If a value is not provided for one of the option(s) [after, before, category, count, membership_state, modified_since, order, public_profile_url, role, scope, secure_urls, show_hidden_members, start, type] either in the endpoint URI or in a message header, it will be assumed to be null. Note that the null value(s) will only be used if other options do not satisfy matching endpoints.
Name | Type |
---|---|
activity | org.apache.camel.component.linkedin.api.model.Activity |
after | Long |
before | Long |
category | org.apache.camel.component.linkedin.api.Category |
company | org.apache.camel.component.linkedin.api.model.Company |
company_id | Long |
count | Long |
fields | String |
group_id | Long |
groupmembership | org.apache.camel.component.linkedin.api.model.GroupMembership |
isliked | org.apache.camel.component.linkedin.api.model.IsLiked |
job_id | Long |
jobbookmark | org.apache.camel.component.linkedin.api.model.JobBookmark |
mailboxitem | org.apache.camel.component.linkedin.api.model.MailboxItem |
membership_state | org.apache.camel.component.linkedin.api.model.MembershipState |
modified_since | Long |
order | org.apache.camel.component.linkedin.api.Order |
person_id | String |
public_profile_url | String |
role | org.apache.camel.component.linkedin.api.Role |
scope | String |
secure_urls | Boolean |
share | org.apache.camel.component.linkedin.api.model.Share |
show_hidden_members | Boolean |
start | Long |
type | org.apache.camel.component.linkedin.api.Type |
update_key | String |
updatecomment | org.apache.camel.component.linkedin.api.model.UpdateComment |
202.3.6. Endpoint prefix posts
The following endpoints can be invoked with the prefix posts as follows:
linkedin://posts/endpoint?[options]
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
addComment | comment | comment, post_id | |
flagCategory | post_id, postcategorycode | ||
followPost | isfollowing, post_id | ||
getPost | post | count, fields, post_id, start | org.apache.camel.component.linkedin.api.model.Post |
getPostComments | postComments | count, fields, post_id, start | org.apache.camel.component.linkedin.api.model.Comments |
likePost | isliked, post_id | ||
removePost | post | post_id |
URI Options for posts
If a value is not provided for one of the option(s) [count, start] either in the endpoint URI or in a message header, it will be assumed to be null. Note that the null value(s) will only be used if other options do not satisfy matching endpoints.
Name | Type |
---|---|
comment | org.apache.camel.component.linkedin.api.model.Comment |
count | Long |
fields | String |
isfollowing | org.apache.camel.component.linkedin.api.model.IsFollowing |
isliked | org.apache.camel.component.linkedin.api.model.IsLiked |
post_id | String |
postcategorycode | org.apache.camel.component.linkedin.api.model.PostCategoryCode |
start | Long |
202.3.7. Endpoint prefix search
The following endpoints can be invoked with the prefix search as follows:
linkedin://search/endpoint?[options]
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
searchCompanies | companies | count, facet, facets, fields, hq_only, keywords, sort, start | org.apache.camel.component.linkedin.api.model.CompanySearch |
searchJobs | jobs | company_name, count, country_code, distance, facet, facets, fields, job_title, keywords, postal_code, sort, start | org.apache.camel.component.linkedin.api.model.JobSearch |
searchPeople | people | company_name, count, country_code, current_company, current_school, current_title, distance, facet, facets, fields, first_name, keywords, last_name, postal_code, school_name, sort, start, title | org.apache.camel.component.linkedin.api.model.PeopleSearch |
URI Options for search
If a value is not provided for one of the option(s) [company_name, count, country_code, current_company, current_school, current_title, distance, facet, facets, first_name, hq_only, job_title, keywords, last_name, postal_code, school_name, sort, start, title] either in the endpoint URI or in a message header, it will be assumed to be null. Note that the null value(s) will only be used if other options do not satisfy matching endpoints.
Name | Type |
---|---|
company_name | String |
count | Long |
country_code | String |
current_company | String |
current_school | String |
current_title | String |
distance | org.apache.camel.component.linkedin.api.model.Distance |
facet | String |
facets | String |
fields | String |
first_name | String |
hq_only | String |
job_title | String |
keywords | String |
last_name | String |
postal_code | String |
school_name | String |
sort | String |
start | Long |
title | String |
202.4. Consumer Endpoints
Any of the producer endpoints can be used as a consumer endpoint. Consumer endpoints can use http://camel.apache.org/polling-consumer.html#PollingConsumer-ScheduledPollConsumerOptions[Scheduled Poll Consumer Options] with a consumer. prefix to schedule endpoint invocation. By default Consumer endpoints that return an array or collection will generate one exchange per element, and their routes will be executed once for each exchange. To change this behavior use the property consumer.splitResults=true to return a single exchange for the entire list or array.
202.5. Message Headers
Any URI option can be provided in a message header for producer endpoints with a CamelLinkedIn. prefix.
202.6. Message body
All result message bodies utilize objects provided by the Camel LinkedIn API SDK, which is built using Apache CXF JAX-RS. Producer endpoints can specify the option name for incoming message body in the inBody endpoint parameter.
202.7. Use cases
The following route gets user’s profile:
from("direct:foo") .to("linkedin://people/person");
The following route polls user’s connections every 30 seconds:
from("linkedin://people/connections?consumer.timeUnit=SECONDS&consumer.delay=30") .to("bean:foo");
The following route uses a producer with dynamic header options. The personId header has the LinkedIn person ID, so its assigned to the CamelLinkedIn.person_id header as follows:
from("direct:foo") .setHeader("CamelLinkedIn.person_id", header("personId")) .to("linkedin://people/connectionsById") .to("bean://bar");