Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
simple-linkedin-post
Advanced tools
simple-linkedin-post is a Node.js package designed to simplify LinkedIn posting, focusing on image and video posts.
simple-linkedin-post is a Node.js package designed to simplify LinkedIn posting, focusing on image and video posts.
Package Initialization
import LinkedInApi from 'simple-linkedin-post';
import express from 'express';
import multer from 'multer';
Initialize Express App
const app = express();
const port = 8081; // Change to any available port number
Setup Multer for File Uploads
const storage = multer.memoryStorage();
const upload = multer({ storage: storage });
Configure LinkedIn API Credentials
const clientID = "xxxx"
const clientSecret = "xxxx"
const redirectURL = "xxxx"
const scope = "xxxxx"
Initialize LinkedIn API
const linkedIn = new LinkedInApi(clientID, clientSecret, redirectURL, scope);
linkedIn.auth(app);
Image Post Creation
This example demonstrates how to create an image post on LinkedIn.
app.post('/createImgPost', upload.single('file'), async (req, res) => {
const accessToken = "xxx"
if (!accessToken) {
return res.status(400).json({ message: 'Access token is missing.' });
}
if (req.file) {
try {
const fileBuffer = req.file.buffer;
const response = await linkedIn.createImagePost(
"T0qsRQ6IIP", // User ID
{
imgTitle: "Sample Image",
imgDescription: "This is an image description",
displayContent: "Feeling inspired after meeting so many talented individuals at this year's conference. #talentconnect"
},
accessToken,
fileBuffer
);
return res.json(response);
} catch (error) {
console.error('Error creating image post:', error);
return res.status(500).json({
message: 'Failed to create image post.',
error: error.message,
});
}
} else {
return res.status(400).json({ message: 'No file uploaded.' });
}
});
Video Post Creation
This example demonstrates how to create an video post on LinkedIn.
app.post('/createVideoPost', upload.single('file'), async (req, res) => {
const accessToken = "xxx"
if (!accessToken) {
return res.status(400).json({ message: 'Access token is missing.' });
}
if (req.file) {
try {
const fileBuffer = req.file.buffer;
const response = await linkedIn.createVideoPost(
"T0qsRQ6IIP", // User ID
{
imgTitle: "Sample Video",
imgDescription: "This is a video description",
displayContent: "Feeling inspired after meeting so many talented individuals at this year's conference. #talentconnect"
},
accessToken,
fileBuffer
);
return res.json(response);
} catch (error) {
console.error('Error creating video post:', error);
return res.status(500).json({
message: 'Failed to create video post.',
error: error.message,
});
}
} else {
return res.status(400).json({ message: 'No file uploaded.' });
}
});
Start the application and navigate to the browser.
Visit the following URL to be redirected to the LinkedIn login page:
http://localhost:8081/linkedin/auth
Login to LinkedIn: After logging in successfully, you will be redirected to the callback URL to obtain the access token.
The callback URL is:
http://localhost:8081/linkedin/callback
FAQs
simple-linkedin-post is a Node.js package designed to simplify LinkedIn posting, focusing on image and video posts.
The npm package simple-linkedin-post receives a total of 0 weekly downloads. As such, simple-linkedin-post popularity was classified as not popular.
We found that simple-linkedin-post 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.