Purpose 😑
Linkedin APIs were used to automate your post, which was then combined with a JSON API for a random meme pulled from Reddit, which is maintained by @D3vd and set up using GitHub action.
📓 you can also write that script in bash or python which is well suited for that type of work.
How to install 😒
You can utilise that script by Using Nodejs.
here is by using Nodejs.
- Click on the green Clone button or choose Download ZIP.
- Find the downloaded zipped file on your pc and extract it.
- Install
nodejs and NPM in your local system.
- Open the Root Directory, navigate to LinkedinAutomation using the command
cd LinkedinAutomation and use either npm install or pnpm install to install all dependencies.
- After that, configure these values in the
.env file:
BASE_URL=https://api.linkedin.com/v2
MEMES_URL=https://meme-api.com/gimme
CLIENT_ID=
CLIENT_SECRET=
REDIRECT_URI=
ACCESS_TOKEN=
- Then run
npm start or pnpm start. Now you can see this output:
LinkedIn post created successfully: { id: 'urn:li:share:7078778985983164433' }
which is show your post is created successfully.
How to automate using github-actions.
You can always set that script in your local system by using corn job to upload posts on LinkedIn or you can use github-action for this work.
here is to set GitHub action to run that script with a fixed interval of time.
- Go to your action tab and create action and paste that code:
name: Run Node.js Script
on:
push:
branches: master
schedule:
- cron: "0 */24 * * *"
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BASE_URL: ${{ secrets.BASE_URL }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
MEMES_URL: ${{ secrets.MEMES_URL }}
REDIRECT_URI: ${{ secrets.REDIRECT_URI }}
jobs:
run-script:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "16"
- name: Install dependencies
run: npm install
- name: Run script
run: node src/main.js
- you can set interval which you want to upload your post on linkedin by seting
cron: "0 */24 * * *" in above action.
- Go to your repo setting and open that section and set these envroments:
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BASE_URL: ${{ secrets.BASE_URL }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
MEMES_URL: ${{ secrets.MEMES_URL }}
REDIRECT_URI: ${{ secrets.REDIRECT_URI }}
like this:

Now your script is good to go.
评论