Send a Newsletter Using ConvertKit API
cast_send_newsletter.RdThe send_newsletter function sends a
newsletter created using metadata
extracted from a blog post's front matter.
It communicates with the
ConvertKit API to create and schedule an
email broadcast.
Arguments
- frontmatter
A named list containing metadata extracted from the blog post YAML. The list should include the following fields:
seoA string containing the SEO description for the blog post.
imageA string with the relative path to the blog post's thumbnail image.
titleA string containing the blog post's title.
- url
Character, url of the post.
Value
This function does not explicitly
return a value (NULL). It performs
a side effect by sending a newsletter
through the ConvertKit API.
Details
The function generates the HTML content for
the newsletter using the glue
package (placeholders for custom templates
need to be defined). It then
constructs an HTTP POST request to the
ConvertKit API, passing various fields
such as the email subject, thumbnail_url,
and content. The API key for
authentication is fetched from the
environment variable KIT_SECRET.
Examples
if (FALSE) { # \dontrun{
# Example frontmatter
frontmatter <- list(
seo = "This is an amazing blog post about R programming!",
image = "images/blog-thumbnail.jpg",
title = "Learning R Programming"
)
# Sending a newsletter
send_newsletter(frontmatter)
} # }