Monok News Logo

Integration

There are multiple ways of integrating with established publishing tools. Monok allows the user to automatically generate a draft from the chosen article, by pushing the content to their system of choice. You can also automatically publish from Monok directly to your WordPress website, custom backend system or to your teams slack channel.

WordPress

A WordPress plugin is available that allows you to push out any article of your choice to your WordPress admin as a new draft. Once the plugin is installed, a settings page will appear on your WordPress admin, where you can choose the default category, resolution of the featured image and other important settings.

  • Automatic category/section matching
  • Automatic featured image setup
  • Choose post type
  • Choose the default author
  • Quotes are styled according to your theme
  • All embedded content is pushed (Youtube Video, Instagram Post, Twitter Post etc)
  • Choose the resolution of photos
  • Automatic interlinking to other posts on your site
  • Keeping track of what your own team writes so to avoid duplicate

Installation

  1. Download the WordPress plugin from your settings page and install it in your WordPress admin for the website you wish to integrate with, it is important to remember that each user has a unique and private plugin, that contains your API key and should not be shared with others.
  2. Go to your monok profile and check if your website has synced with Monok; if not, add the URL of your WordPress admin to your list of WordPress websites.

That’s it, you can then start pushing out articles by opening up an article, pressing push to WordPress and choosing your WordPress URL.

API

The API endpoints are for our business customers to migrate and store generated content, they are not for serving the content for a website nor are they suitable for on-demand access. Thus the access limits are strict, we recommend our clients to maintain their own backend and database, access the Monok API periodically to refresh their database with newly generated content.

Receive articles from Monok

Any article can be pushed to your backend-system from our frontend using our Push Article API. It’s the easiest way to integrate with Monok to your custom CMS website or native application. All you need to do is open up an API endpoint in your own backend with the suffix /monok, the endpoint should also take a token to verify the request is coming from your Monok account, that token is always your own API-key.

Type: POST-Request Example: https://www.myOwnWebsite.com/monok

Monok will use this method to push out an article to your backend

$ curl -XPOST -i https://www.myOwnWebsite.com/monok' 
-H "Content-Type: applicatiGETon/json" 
-H "token: [ API-Key ]"

Add the endpoint as a new intergration in your Monok settings page. You will then be able to push your articles from the dropdown menu of any article as such:

This is also how articles can be pushed automatically to your website once a human edit is complete and submitted.

Article Text Format

The article text is formatted using markdown with occasional JSON injections representing widgets, that is: Embedded X/Tweets, Instagram posts, YouTube videos or Quotes. Here’s an example of how a post from X/Twitter can look like injected into an article.

{
    "data":
    [
        {
            "name": "Phil Spencer",
            "text": "Had good calls this week with leaders at Sony. I confirmed our intent to honor all existing agreements upon acquisition of Activision Blizzard and our desire to keep Call of Duty on PlayStation. Sony is an important part of our industry, and we value our relationship.January 20, 2022"
        }
    ],
    "id": "1484273335139651585",
    "type": "twitter",
    "url": "https://twitter.com/XboxP3/status/1484273335139651585",
    "username": "XboxP3"
}

We recommend splitting the article text at every newline (\n) and validating whether the item is markdown text or a JSON-object.Depending on which it is, you can compile the markdown to HTML and the JSON-object to your own HTML compiler.

In WordPress for instance, markdown should be compiled to HTML and JSON should be evaluated, for X/Twitter objects and YouTube object, inserting the URL field is sufficient for WordPress to understand that this is an embedded tweet or YouTube video, whilst for Instagram posts, you will need to insert an iFrame directed to the URL.

We recommend using Drawdown by Adam Legget, as it is small (~4 KB), and compiles Monok articles well, into HTML.

Featured Image

An article JSON also comes with a thumbnail URL, this is the easiest way to download the visual focus object – more commonly known as a “featured image” – as a photo.

We however strongly recommend using the “thumbImageData” field in the JSON deliverable. This is a base64 encoding of a PNG photo. You should always try to favor this photo over any thumbnail url or visual focus object. This is the whole photo provided to you for storing in your image database, as a PNG file, compressed, based on your preferences as configured in the Monok subscription feed settings.

If you’re not interested in re-building the article text into HTML for your Strapi or WordPress integration, then we recommend using the HTML field in the JSON, this field provides you with the whole article, as a WordPress ready HTML rendition.

Many servers limit the amount of data you can send to them. When a thumbImageData field is sent, it can exceed that limit (If high quality is chosen in the feed settings), thus yielding a 413 Payload Too Large error. To resolve this issue, make sure your Nginx value for client_max_body_size is larger than 5mb.

Send Back Data

When an article is published on your system, you have the option to send information about the article back to Monok. The are several benefits to doing this.

  1. You will double-link the articles so you may access the published article from Monok
  2. When new articles are published, they will include links to previously published articles if you’ve activated Interlinking (on by default)

The target URL is /api/v1/linkback, it takes a POST request with the following JSON body:

{
    "puff":
    {
        "title": "Governor Greg Abbott on Texas repercussion of severe winter weather",
        "article": "Governor Greg Abbott to be briefed on the effects of heavy winter weather on Texas at the Alternate State Operations Center [...]"
    },
    "id": "1t8e9-governor-greg-abbott-on-texas-repercussion-of-severe-winter-weather",
    "url": "https://www.natureclimatechange.com/governor-greg-abbott-on-texas-repercussion-of-severe-winter-weather/",
    "source": "natureclimatechange.com",
    "userId": "natureclimatechange.com-WP",
    "thumbnail": "https://www.natureclimatechange.com/wp-content/uploads/2022/02/3187562f6efb196adeb207e62f392f44_testcollage.png"
}

The “id” refers to the Monok article Id, whilst the userId is just a unique identifier, we propose the domain name plus an identifier for your website, WP for WordPress for instance or Strapi for your Strapi-based CMS.

Troubleshooting

Many servers limit the amount of data you can send to them. When a thumbImageData field is sent, it can exceed that limit, thus yielding a 413 Payload Too Large error. To resolve this issue, make sure your Nginx value for client_max_body_size is larger than 5mb.

In some cases, the website has limited POST and GET calls by restriction of endpoints through Nginx. To resolve this, open up the following endpoint:

website.com/wp-json/monok/*

The wildcard is there because there are two paths, Nginx configurations understand wildcards

If your Nginx setup resitricts IP’s, open it up for this address: 51.15.93.77

Embedding content such as tweets is easy with WordPress. By default Monok inserts the url for a youtube or a tweet as new line in the text. If you’ve disabled this feature on WordPress, you can instead embed as HTML or as a shortcode.

Our shortcode for twitter is:

 [twitter url=”…”]