
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
linkedin-post-reaction-api
Advanced tools
This npm package provides a simple and convenient way to interact with the LinkedIn API for creating, editing, deleting, and retrieving posts, as well as handling reactions.
To install the package, run:
npm install linkedin-post-reaction-api
First, import the necessary classes from the package:
import { PostAPI, ReactionAPI } from 'linkedin-post-reaction-api';
You need to initialize the API clients with your LinkedIn access token:
const accessToken = 'YOUR_ACCESS_TOKEN';
const postAPI = new PostAPI(accessToken);
const reactionAPI = new ReactionAPI(accessToken);
To create a post, use the createPost
method:
const urn = 'YOUR_PERSON_URN';
const text = 'This is a new post!';
const media = [
{
status: 'READY',
description: {
text: 'Image description'
},
media: 'urn:li:digitalmediaAsset:D4D2OAQF3kWv4gHmWlw',
title: {
text: 'Image title'
}
}
];
const type = 'IMAGE';
postAPI
.createPost(urn, text, media, type)
.then((response) => {
console.log('Post created:', response);
})
.catch((error) => {
console.error('Error creating post:', error);
});
To edit a post, use the editPost
method:
const postUrn = 'urn:li:ugcPost:123456';
const newText = 'This is an edited post!';
const newMedia = [
{
status: 'READY',
description: {
text: 'New image description'
},
media: 'urn:li:digitalmediaAsset:D4D2OAQF3kWv4gHmWlw',
title: {
text: 'New image title'
}
}
];
const type = 'IMAGE';
postAPI
.editPost(postUrn, newText, newMedia, type)
.then((response) => {
console.log('Post edited:', response);
})
.catch((error) => {
console.error('Error editing post:', error);
});
linkedin-post-reaction-api
To delete a post, use the deletePost
method:
const postUrn = 'urn:li:ugcPost:123456';
postAPI
.deletePost(postUrn)
.then((response) => {
console.log('Post deleted:', response);
})
.catch((error) => {
console.error('Error deleting post:', error);
});
To retrieve a post, use the getPost
method:
const postUrn = 'urn:li:ugcPost:123456';
postAPI
.getPost(postUrn)
.then((response) => {
console.log('Post retrieved:', response);
})
.catch((error) => {
console.error('Error retrieving post:', error);
});
To create a multi-image post, use the createMultiImagePost
method:
const urn = 'YOUR_PERSON_URN';
const text = 'This is a multi-image post!';
const images = [
'urn:li:digitalmediaAsset:D4D2OAQF3kWv4gHmWlw',
'urn:li:digitalmediaAsset:D4D2OAQF3kWv4gHmXyz'
];
postAPI
.createMultiImagePost(urn, text, images)
.then((response) => {
console.log('Multi-image post created:', response);
})
.catch((error) => {
console.error('Error creating multi-image post:', error);
});
To create a poll post, use the createPollPost
method:
const urn = 'YOUR_PERSON_URN';
const text = 'This is a poll post!';
const options = ['Option 1', 'Option 2', 'Option 3'];
const duration = 604800; // Duration in seconds (e.g., 1 week)
postAPI
.createPollPost(urn, text, options, duration)
.then((response) => {
console.log('Poll post created:', response);
})
.catch((error) => {
console.error('Error creating poll post:', error);
});
To create an event post, use the createEventPost
method:
const urn = 'YOUR_PERSON_URN';
const text = 'This is an event post!';
const eventDetails = {
name: 'Event Name',
time: '2023-10-01T10:00:00Z',
description: 'Event description'
};
postAPI
.createEventPost(urn, text, eventDetails)
.then((response) => {
console.log('Event post created:', response);
})
.catch((error) => {
console.error('Error creating event post:', error);
});
To create a celebration post, use the createCelebrationPost
method:
const urn = 'YOUR_PERSON_URN';
const text = 'This is a celebration post!';
const celebrationDetails = {
type: 'WORK_ANNIVERSARY',
description: 'Celebrating 5 years at the company!'
};
postAPI
.createCelebrationPost(urn, text, celebrationDetails)
.then((response) => {
console.log('Celebration post created:', response);
})
.catch((error) => {
console.error('Error creating celebration post:', error);
});
To add a reaction to a post, use the addReaction
method:
const postUrn = 'urn:li:ugcPost:123456';
const reactionType = 'LIKE';
reactionAPI
.addReaction(postUrn, reactionType)
.then((response) => {
console.log('Reaction added:', response);
})
.catch((error) => {
console.error('Error adding reaction:', error);
});
To delete a reaction from a post, use the deleteReaction
method:
const reactionUrn = 'urn:li:reaction:123456';
reactionAPI
.deleteReaction(reactionUrn)
.then((response) => {
console.log('Reaction deleted:', response);
})
.catch((error) => {
console.error('Error deleting reaction:', error);
});
To retrieve reactions for a post, use the getReactions
method:
const postUrn = 'urn:li:ugcPost:123456';
reactionAPI
.getReactions(postUrn)
.then((response) => {
console.log('Reactions retrieved:', response);
})
.catch((error) => {
console.error('Error retrieving reactions:', error);
});
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
FAQs
A client for the LinkedIn Post and Reaction API
We found that linkedin-post-reaction-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.