New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

simple-linkedin-post

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-linkedin-post

simple-linkedin-post is a Node.js package designed to simplify LinkedIn posting, focusing on image and video posts.

  • 1.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-88.89%
Maintainers
0
Weekly downloads
 
Created
Source

🚀 Usage

simple-linkedin-post is a Node.js package designed to simplify LinkedIn posting, focusing on image and video posts.

🛠️ Setup

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);

📝 Examples

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.' });
    }
});

🔑 Get Access Token

  1. 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
    
  2. 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
    

Keywords

FAQs

Package last updated on 05 Jan 2025

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc