Webhooks
Webhooks are only available in the business plan and the trial period.
You can set up one webhook URL per website in the console's API & Webhooks section. Once you set it up, we will send a HTTP POST request to that URL when a new comment is published, edited, or deleted on a page.
Setting Up Webhooks
Visit Moderate -> API & Webhooks section of the console. Adding a valid webhook URL will turn on webhooks automatically. Then, select the types of events you want to receive. All events are turned on by default.
URL:
- Use a valid absolute URL
- Use https (highly recommended)
Important to Know
- Webhooks are not sent in real-time. There can be a delay of 30 seconds maximum for each event.
- For webhook requests, we expect a 200 OK response code from your server. If the request fails (we get any other response code), we will retry two more times. After that, we will mark the webhook request as failed and stop sending any other requests for that event.
- You can track last 15 webhook events from the console (Click Show Webhooks History).
HTTP POST Request
Post Params:
{
"type": "Event type of the webhook",
"passcode": "SHA1-hashed API Key",
"data": "JSON-encoded Comment Object"
}
Three parameters are sent via POST.
- type -
create
,edit
, ordelete
. (Event type) - passcode - If you have generated an API key for your website, this will be a sha1 hashed version of it.
- data - a JSON-encoded string of a standard comment object (Same as the API).
Validating Webhooks
To validate webhooks, you can use simple string comparison with the passcode
.
if (sha1(MY_API_KEY) == post.passcode) {
// valid
} else {
// invalid
}
Decoding JSON
To get comment data, decode the data
post param.
commentObj = json_decode(post.data);