Skip to main content

CMS Integration via API

Technical description of a possible integration into the customer's CMS

Written by Tobias Oberascher

One of the most important aspects of using Pinpoll in daily editorial work is seamless integration with the client's CMS, such as LivingDocs or other providers.

Ideally, this process is supported by Pinpoll Inspire - our AI solution for creating polls (see Step 2).

In this article, we'll go into detail about the technical implementation in four simple steps.

1) Request a Token

curl -X POST "https://account.pinpoll.com/api/v1/login"
-H "Accept: application/json"
-H "Content-Type: application/json"
--data-raw '{"email":"myemail","password":"mypassword"}'

This request returns a JWT token:

{"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ…", }

This token must be sent with all API calls. After 60 minutes, the token expires (token_expired error) and must then be refreshed via the following route: https://account.pinpoll.com/api/v1/auth/refresh

Alternatively, you can simply log in again. After 14 days of inactivity, the token becomes invalid (token_invalid error), and a new login is required.

2) Generate a poll suggestion (optional)

curl --get 'https://inspire.pinpoll.com/gen/poll/text'
--data-urlencode 'title=Fuel ​​prices are rising'
--data-urlencode 'text=Fuel ​​prices continue to rise; fewer and fewer people can afford gasoline'
--data-urlencode 'domain=mydomain.com'

Note: Specifying the "domain" parameter is important to use the prompt tailored for your needs with our team is actually being used.

This request returns a poll proposal as JSON:

{"polls":[{"question":"How would rising fuel prices most change your daily life?","answers":["I would significantly reduce my trips."","I would use public transportation more often."","I would switch to a more fuel-efficient car."","I would better combine and plan my journeys."],"note":"Created with OAI"}],"category":24,"og_image":null,"og_site_name":null,"title":"Fuel Prices Are Rising","text":"Fuel prices continue to rise, and fewer and fewer people can afford gasoline","domain":null}

3) Create a Poll

With a valid token, you can then create the poll (Note: "audience_id" = "category" which you receive in step 1, e.g., "24" in our example):

curl -X POST "https://tools.pinpoll.com/v3/polls/simple" \
-H "Authorization: Bearer token" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
--data-raw '{
"question": "How would rising fuel prices most change your daily life?",
"audience_id": 24,
"answers": ["I would significantly reduce my trips.", "I would use public transportation more often."","I would switch to a more fuel-efficient car."","I would better combine and plan my journeys."]
}'

This request returns a poll ID, which you can then use in the placeholder:

{"status":"success","data":{"element":{"id":123456789}}}

4) Inserting the placeholder

Using the poll ID, you can finally place the placeholder via the CMS to the article:

<div data-pinpoll-id="123456789" data-version="v2"></div>

That's it! 🚀

If you have any questions, feel free to contact us via chat and we'll schedule a call with our tech teams.

Did this answer your question?