Loudvoice API \ Comments \ Create a comment
LoudVoice API Resources
Resource/URI - Discussions | GET | POST | PUT | DELETE |
---|---|---|---|---|
Discussions
/loudvoice/discussions.json
|
List all discussions | Create a discussion | – | – |
Discussion
/loudvoice/discussions/<discussion_token>.json
|
Read a discussion | – | Update a discussion | Delete a discussion |
Discussion messages
/loudvoice/comments/<discussion_token>/comments.json
|
Read discussion comments | – | – | – |
Resource/URI - Authors | GET | POST | PUT | DELETE |
---|---|---|---|---|
Authors
/loudvoice/authors.json
|
List all authors | Create an author | – | – |
Author
/loudvoice/authors/<author_token>.json
|
Read an author | – | Update an author | Delete an author |
Resource/URI - Author Sessions | GET | POST | PUT | DELETE |
---|---|---|---|---|
Author Sessions
/loudvoice/authors/sessions.json
|
List all sessions | – | Create or update a session | – |
Author Session
/loudvoice/authors/sessions/<session_token>.json
|
– | – | – | Delete a session |
Resource/URI - Comments | GET | POST | PUT | DELETE |
---|---|---|---|---|
Comments
/loudvoice/comments.json
|
List all comments | Create a comment | – | – |
Comment
/loudvoice/comments/<comment_token>.json
|
Read a comment | – | Update a comment | Delete a comment |
Resource/URI - Votes | GET | POST | PUT | DELETE |
---|---|---|---|---|
Votes
/loudvoice/votes.json
|
List all votes |
– | – | – |
Vote
/loudvoice/votes/comments/<comment_token>/authors/<author_token>.json
|
Read a vote | – | Cast a vote | Delete a vote |
Workflow
Request: the code to send to the API
Send an API request to this endpoint in order to add a new comment to a discussion:
POST
/loudvoice/comments.json
POST
data to be included in the request
{ "request": { "do_moderation": "#do_moderation#", "comment": { "comment_reference": "#comment_reference#", "parent_comment_token": "#parent_comment_token#", "parent_comment_reference": "#parent_comment_reference#", "text": "#text#", "ip_address": "#ip_address#", "has_been_approved": #has_been_approved#, "is_spam": #is_spam#, "is_trashed": #is_trashed#, "date_creation": "#date_creation#", "votes": { "num_votes_up": #num_votes_up#, "num_votes_down": #num_votes_down#, "date_last_vote": "#date_last_vote#" }, "author": { "author_token": "#author_token#", "author_reference": "#author_reference#" }, "discussion": { "discussion_token": "#discussion_token#", "discussion_reference": "#discussion_reference#" } } } }
Key | Description |
---|---|
Flag | |
do_moderationboolean
|
If enabled, the value for has_been_approved
will be set based on the settings in your OneAll account and trying to create a comment that contains
blacklisted keywords will return an error.Default: false |
Reference | |
comment_referencestring
|
Your custom reference for this comment. This value is unique amongst all comments of the same discussion. Example: POST-1234 |
Comment Parent | |
Optionally use one of these fields to indicate the parent comment. | |
parent_comment_tokenstring, uuid-v4
|
The comment_token of and existing comment. Example: f7cab4f8-43ae-4e1a-97e8-63e22f94923d |
parent_comment_referencestring
|
The comment_reference of and existing comment. Example: POST-1234 |
Comment Metadata | |
* textstring
|
The comment contents. Example: Hello world! This is my first comment. |
ip_addressstring, IPv4
|
The IP address that was used to publish the comment. Example: 127.0.0.1 |
has_been_approvedboolean
|
Indicates whether the comment has been approved or not. The LoudVoice widget displays comments
that have not been approved only to it's author. Default: true |
is_spamboolean
|
Indicates whether the comment has been flagged as spam or not. The LoudVoice widget does not display comments flagged as spam. Default: false |
is_trashedboolean
|
Indicates whether the comment has been trashed or not. The LoudVoice widget does not display trashed comments. Default: false |
date_creationstring, RFC 2822
|
Date indicating when the comment was posted. If left empty, the current date will be used. Example: Wed, 14 Mar 2018 14:19:49 +0100 |
Comment Votes | |
The number of votes is calculated automatically. Use these fields to manually offset the internal counters. | |
num_votes_upinteger
|
Number of times this comment has been voted up. Example: 42 |
num_votes_downinteger
|
Number of times this comment has been voted down. Example: 28 |
date_last_votestring, RFC 2822
|
Date of the last vote. Example: Wed, 14 Mar 2018 14:19:49 +0100 |
* Comment Author | |
One of these fields is required to indicate the comment author. | |
author_tokenstring, uuid-v4
|
The token indicating the author of the comment. Example: f7cab4f8-43ae-4e1a-97e8-63e22f94923d |
author_referencestring
|
Your custom reference indicating the author of the comment. Example: USER-1234 |
* Comment Discussion | |
One of these fields is required to indicate the discussion the comment is part of. | |
discussion_tokenstring, uuid-v4
|
The token indicating the discussion the comment is part of. Example: f7cab4f8-43ae-4e1a-97e8-63e22f94923d |
discussion_referencestring
|
Your custom reference indicating the discussion the comment is part of. Example: PAGE-1234 |
Result: the code returned by the API
The API will either return a HTTP status code 201
if the comment was created or an appropriate message body with
further details on the error that occured.
Resultset Example
{ "response": { "request": { "date": "Fri, 01 Apr 2018 11:30:02 0200", "resource": "/loudvoice/comments.json", "status": { "flag": "created", "code": 201, "info": "Your request has been processed successfully and resulted in a new resource being created" } }, "result": { "data": { "comment": { "comment_token": "919c030f-c63b-4f64-8a89-8eff90bcbc86", "comment_reference": "COMMENT-ABC123", "parent_comment_token": null, "parent_comment_reference": null, "date_creation": "Fri, 01 Apr 2018 11:30:02 0200", "date_last_update": null, "post_order": 39, "has_been_approved": true, "is_spam": false, "is_trashed": false, "ip_address": "127.0.0.1", "text": "Hello World! This is my first comment.", "votes": { "num_votes_up": 0, "num_votes_down": 0, "date_last_vote": null }, "reports": { "num_reports": 0, "date_last_report": null }, "author": { "author_token": "71e944f8-394e-4808-9c00-163928c59ba8", "author_reference": "USER-46435", "name": "John Smith", "email": "john-smith@example.com", "description": null, "picture_url": "https://www.example.com/john-smith/avatar.png", "website_url": "https://www.example.com/john-smith/", "num_comments": 13, "date_last_comment": "Fri, 01 Apr 2018 11:30:02 0200", "date_creation": "Tue, 27 Mar 2018 11:19:52 0200", "date_last_update": "Fri, 01 Apr 2018 11:30:02 0200" }, "discussion":{ "discussion_token": "b0ad71f8-0323-486c-916f-0c3f767f6174", "discussion_reference": "PAGE-32423", "date_creation": "Tue, 27 Mar 2018 10:58:21 0200", "title": "Loudvoice Documentation", "url":"http:s//docs.oneall.com/", "is_closed": false, "is_trashed": false, "num_comments": 39, "date_last_comment": "Fri, 01 Apr 2018 11:30:02 0200", "date_last_update": "Tue, 27 Mar 2018 10:58:24 0200" } } } } } }