Skip to contents

This function publishes a new post to LinkedIn using the specified author, text content, optional image, and associated image alt text. It supports adding media attachments and retries requests for transient errors.

Usage

li_post_write(author, text, image = NULL, image_alt = "")

Arguments

author

A string representing the unique LinkedIn author URN (Uniform Resource Name).

text

A string representing the textual content of the LinkedIn post. The text is escaped to ensure LinkedIn compatibility.

image

(Optional) A string representing the file path to the image that will be attached to the post. Defaults to NULL if no image is included.

image_alt

(Optional) A string representing the alternate text for the image (e.g., for accessibility). Defaults to an empty string "".

Value

Invisibly returns the LinkedIn post ID as a string. Displays a message with the LinkedIn URL for the published post.

Details

If an image is provided, the function automatically uploads the image to LinkedIn using the li_media_upload() helper function (not defined here). The post is configured for public visibility and main feed distribution. Error retries are applied for certain HTTP status codes.

Examples

if (FALSE) { # \dontrun{
# Publish a simple text post:
li_post_write(
  author = "urn:li:person:exampleAuthor",
  text = "This is a simple LinkedIn post!"
)

# Publish a post with an image:
li_post_write(
  author = "urn:li:person:exampleAuthor",
  text = "Check out this image!",
  image = "path/to/image.jpg",
  image_alt = "A description of the image for accessibility"
)
} # }