How to vote content

THRON API provide some web services that allow users to implement the "vote" functionality for content in different integrations (websites, application etc.).

 

Make content eligible for voting

 

The first thing to do is to make sure that the content can be voted, this information can be retrieved among the content properties, so just invoke a getContentDetail to see if you get the property "RATING_ALLOWED"; if not you will have to enable it by invoking an updateContent request.

The URL of the webservice is structured as follows:

//<clientId>-view.thron.com/api/xcontents/resources/content/updateContent

It is a POST request, hence a valid token must be included among the request headers in the form: "X-TOKENID: <yourTokenIdHere>".

In the body of the request you can paste the following JSON:


{
    "clientId": "",
    "contentId": "",
    "contentValues": {
        "properties": [
            "RATING_ALLOWED"
        ]
    }
}    

 

 

Vote content

 

Once the content has been made eligible for voting you will just have to invoke an insertRating request.

The url of the request is structured as follows:

//<clientId>-view.thron.com/api/xcontents/resources/ratingfixedrange/insertRating

 

It is a POST request, hence a valid token must be included among the request headers in the form: "X-TOKENID: <yourTokenIdHere>".

In the body of the request you can paste the following JSON:


{
    "clientId": "",
    "contentId": "",
    "score": 0,
    "userId": ""
}    

 

Where:

  • score (decimal, mandatory): it is the actual rating attributed to the content. A decimal number between 0 and 1.
  • userId (string, optional): a reference to the user providing the vote: can be a username, an id, a full name or any other reference to the user.

 

Get total votes on a specific content

 

In order to get the total rating of a specific content you can invoke the specific GET request: getContentScore, whose URL is structured as follows:

//<clientId>-view.thron.com/api/xcontents/resources/ratingfixedrange/getContentScore?clientId=<clientId>&contentId=<xcontentId>

 

Find rating by properties

 

Finally there's a specific web service which can be used in order to retrieve specific votes on a content filtering by time interval or specific user, which is the findRatingByProperties. The url of the request is structured as follows:

//<clientId>-view.thron.com/api/xcontents/resources/ratingfixedrange/findRatingByProperties

It is a POST request, hence a valid token must be included among the request headers in the form: "X-TOKENID: <yourTokenIdHere>".

In the body of the request you can paste the following JSON:


{
    "clientId": "",
    "contentId": "",
    "criteria": {
        "fromDate": "",
        "toDate": "",
        "userId": ""
    }
}    

Where:

  • fromDate (string, optional): it is the starting date of the time interval to be considered. It has to be expressed in the form: yyyy-mm-dd. The value of this parameter cannot be older than two months. If you need to retrieve content older than two months you will have to perform an extract request.
  • toDate (string, optional): the end date of the time interval to be considered. It has to be expressed in the form: yyyy-mm-dd.
  • userId (string, optional): a reference to the user who provided the vote: can be a username, an id, a full name or any other reference to the user.
Was this article helpful?
0 out of 0 found this helpful

Have any question?

Open a ticket
Comments