Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

LinkedIn Posts

Utility to share LinkedIn posts using the LinkedIn Marketing API

Made easy to use in Python.

Installation and Setup

Install with pip

python -m pip install linkedin-posts

Generate LinkedIn's Access Token

The quickest way to get an Access Token is by using the LinkedIn Token generator tool

Usage

Share a post

By the time I am writing this sentence, this is the most useful function of this package.

Share a post by using the function share_post with some arguments.

from linkedin_posts.posts import share_post

response = share_post(
  "<HERE YOUR ACCESS TOKEN>",
  comment="publishing a post",
  author_type="organization",
  author_id="71513925",
)

# Do something with your response object r (http.client.HttpResponse)
# Interesting parameters to check:
# response.getheader("x-restli-id") will return the LinkedIn Post ID
# response.code will return 201 if request proccessed correctly
...

Delete a post

Deleting a post is very straightforward.

Just just need the access token and pass the LinkedIn Post ID.

from linkedin_posts.posts import delete_post

response = delete_post("<HERE YOUR ACCESS TOKEN>", "urn:li:share:7104319981684674560")

# response.code will return 204 if request proccessed correctly

Create a poll post

It is possible to share a post with a poll by using the following code:

from linkedin_posts.polls import share_poll

response = share_poll(
  "<HERE YOUR ACCESS TOKEN>",
  comment="Hello, this is just a test...",
  poll_question="Is this is a nice poll?",
  poll_options=["Yes", "No", "I do not care"],
  author_type="organization",
  author_id="71513925",
)

# do something with response if you need to!

Now go to your LinkedIn page and check your published poll!

image

Post with media

To create a post with a nice picture you can use this code.

# upload a image
upload_request, image_urn = upload_image(
    "<HERE YOUR ACCESS TOKEN>",
    file="img/nicecv.jpg",
    author_type=author_type,
    author_id=author_id,
)

# create a post with the uploaded image
share_post_with_media(
    "<HERE YOUR ACCESS TOKEN>",
    comment="Do you like this nice cv?",
    author_type=author_type,
    author_id=author_id,
    media_id=image_urn
)

And voilà. Here is your post!

image

Metadata

Release files for linkedin-posts 0.0.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for linkedin-posts 0.0.12
File Size Uploaded Provenance Actions
linkedin-posts-0.0.12.tar.gz 8.3 kB Without provenance Details for linkedin-posts-0.0.12.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for linkedin-posts 0.0.12
File Interpreter ABI Platform Actions
linkedin_posts-0.0.12-py3-none-any.whl Python 3 none any Details for linkedin_posts-0.0.12-py3-none-any.whl

Total release size: 17.2 kB

Release files / linkedin-posts-0.0.12.tar.gz

Download URL linkedin-posts-0.0.12.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
cbd2748a2602c1f1c21074d4fd651a7a64dfd2e74fb83f6b1cdaffc2e93ca258
BLAKE2b-256 checksum
How to use checksums
bd01ff2659081afd1ca820f54b5bf57bf30d955625e7a37e97262eb452133d58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/42.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

Release files / linkedin_posts-0.0.12-py3-none-any.whl

Download URL linkedin_posts-0.0.12-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d17321196192ef130d735cb45da37a0d68f60b04e677a1c28ac40d6dea9f017b
BLAKE2b-256 checksum
How to use checksums
83b747c0fb672d6e6d90107a4426e520f0d46ebcf77c137836efc9e56145c202
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/42.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

Security for linkedin-posts 0.0.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page