Rest Api

EasyDiscuss 4 includes a simple REST api that allows you to connect to EasyDiscuss to perform various tasks.

Posting New Comment

In this section, we will briefly explain the REST API to Posting New Comment.

The REST API call allows requester to post a new comment to a post created on the site. To do so, requester need to send a POST request to this following url:

http://site.com/index.php?option=com_easydiscuss&view=comment&layout=save&format=json&tmpl=component

POST Parameters

The following are the available parameters when a POST is made to this API call:

  • auth (required)
    This auth parameter is the authorization auth token.
  • userId (required)
    This userId parameter is the user id received with the authorization auth token.
  • id (required)
    This id parameter is the post id.
  • content (required)
    This content parameter is the comment content.

Response

Upon a successful request, EasyDiscuss system will return a response in a form of JSON to the requester.

The successful request response will looks similar as below:

{
  "code": 200,
  "data": {
    "comment": {
      "user_id": "960",
      "name": "Haikal Harris",
      "email": "haikal@mail.com",
      "comment": "this is comment from rest api",
      "post_id": "25",
      "permalink": "http://ed.repo/index.php?option=com_easydiscuss&view=post&id=25&Itemid=118&format=json"
    }
  },
  "message": "Comment posted successfully"
}

And a fail request response will looks similar as below:

{
  "code": 404,
  "message": "Invalid username or password"
}