How to use Opinioner API

The Opinioner API allows you to involve users from different sites in the voting process. This means that you can create and customize the voting graph on your main site and paste it via code snippet to another your site to get summarized voting result.

To work with API you need to follow the guide:

Step 1

Go to Opinioner>API> Enable API>press Save changes.

The CORS policy of the server where the plugin is installed must allow requests with JS and CSS files in the place where the API files are located.

step 2

There are a set of settings that work with default values but can be changed if necessary.

API settings

Where:

  • JS snippet – copy the script that needs to be pasted to the website where you want to display the Opinioner voting graph.
  • Files location: select the location for API files. Your server settings must allow the creation of files and folders in the specified location.
  • Directory name: enter the name of the directory where the API files will be located.
Step 3

Paste the JS snippet to the end of the body section of the website where you want to display the Opinioner voting graph. Replace “id” with the ID of your created Opinion post. You can find the ID in the shortcode of a specific post on the page Opinioner>All Opinions. The “selector“replace with the CSS selector of the voting block.

Opinion post ID

Example of inserted JS snippet with id=10 and CSS selector opinioner.

To add multiple voting graphs to one page, you can enter IDs separated by commas.

<script src="http://example.com/opinioner.merkulov.design/opinioner-api/api.min.js?id=10,6&selector=opinioner"></script>
step 4

Go to the page with the voting block selector you specified in the JS snippet to see the Opinioner graph. If the graph is displayed you did everything correctly.

Was this article helpful to you?