Comments synchronization allows you to save Cackle comments in your local database server for storage and indexing by search engines. For synchronization you need to receive comments for each page of your site by using the following API.
HTTP method | Endpoint | Limit | Description |
---|---|---|---|
GET | http://cackle.me/api/3.0/comment/chan/list.json | 1 every 5 seconds | To receive comments on a particular page of the site. A maximum of 100 comments for 1 request. The request data encoding UTF-8. |
Request parameters:
Parameter | Mandatory | Type | Description |
---|---|---|---|
id | Yes | The widget ID | You can get in the admin panel, on menu "Install" tab "CMS Platform" and choose WordPress. |
siteApiKey | Yes | The widget API key | You can get in the admin panel, on menu "Install" tab "CMS Platform" and choose WordPress. |
accountApiKey | Yes | The account API key | You can get in the admin panel, on menu "Install" tab "CMS Platform" and choose WordPress. |
gtModify | No | Date in milliseconds | Passing this parameter, the API will return comments which modification time greater than modified. Without this parameter, you will have all channels |
HTTP method | Endpoint | Limit | Description |
---|---|---|---|
GET | http://cackle.me/api/3.0/comment/list.json | 1 every 5 seconds | To receive comments on a particular page of the site. A maximum of 100 comments for 1 request. The request data encoding UTF-8. |
Request parameters:
Parameter | Mandatory | Type | Description |
---|---|---|---|
id | Yes | The widget ID | You can get in the admin panel, on menu "Install" tab "CMS Platform" and choose WordPress. |
siteApiKey | Yes | The widget API key | You can get in the admin panel, on menu "Install" tab "CMS Platform" and choose WordPress. |
accountApiKey | Yes | The account API key | You can get in the admin panel, on menu "Install" tab "CMS Platform" and choose WordPress. |
chan | Yes | The page ID (channel) | More info about channel. |
commentId | No | The Cackle comment ID | Passing this parameter, the API will return comments which id greater than commentId. Cannot be passed with the modified parameter. |
modified | No | Date in milliseconds | Passing this parameter, the API will return comments which modification time greater than modified. Cannot be passed with the commentId parameter. |
To successfully configure synchronization using this API we recommend the following two actions:
To save all the comments, you must have a list of all channels (chan parameter) on your website.
{"chans":[
{"id":101, "channel": '101', modified: ...},
{"id":102, "channel": '102', modified: ...},
...
{"id":216, "channel": '216'. modified ...}
]}
To save all the comments, you must have a list of all channels (chan parameter) on your website.
{"comments":[
{"id":101, "siteId": ...},
{"id":102, "siteId": ...},
...
{"id":216, "siteId": ...}
]}
Let your site http://mysite.com registered in Cackle with id 1, siteApiKey 123, accountApiKey 321.
According algorithm for getting channel we should do the following things:
http://cackle.me/api/3.0/comment/chan/list.json?id=1&siteApiKey=123&accountApiKey=321
{"chans":[
{"id":1, "channel": '1', url: 'http://mysite.ru/page1',...},
{"id":2, "channel": '2', url: 'http://mysite.ru/page2',...},
{"id":3, "channel": '3', url: 'http://mysite.ru/page3',...}
{"id":4, "channel": '4', url: 'http://mysite.ru/page4',...}
]}
On the supposed site we have 4 pages and each include Cackle comments widget:
According to the algorithm to store all the comments we need to do the following:
http://cackle.me/api/3.0/comment/list.json?id=1&siteApiKey=123&accountApiKey=321&chan=/page1&commentId=0
{"comments":[
{"id":1, "siteId": ...},
{"id":2, "siteId": ...},
{"id":3, "siteId": ...}
]}
http://cackle.me/api/3.0/comment/list.json?id=1&siteApiKey=123&accountApiKey=321&chan=/page2&commentId=0
{"comments":[
{"id":4, "siteId": ...},
{"id":5, "siteId": ...},
...
{"id":104, "siteId": ...}
]}
http://cackle.me/api/3.0/comment/list.json?id=1&siteApiKey=123&accountApiKey=321&chan=/page2&commentId=104
{"comments":[
{"id":105, "siteId": ...},
{"id":106, "siteId": ...},
...
{"id":205, "siteId": ...}
]}
http://cackle.me/api/3.0/comment/list.json?id=1&siteApiKey=123&accountApiKey=321&chan=/page2&commentId=205
{"comments":[
{"id":206, "siteId": ...},
{"id":207, "siteId": ...},
{"id":236, "siteId": ...}
]}
http://cackle.me/api/3.0/comment/list.json?id=1&siteApiKey=123&accountApiKey=321&chan=/page3&commentId=0
{"comments":[
{"id":237, "siteId": ...},
{"id":238, "siteId": ...},
...
{"id":337, "siteId": ...}
]}
http://cackle.me/api/3.0/comment/list.json?id=1&siteApiKey=123&accountApiKey=321&chan=/page3&commentId=337
{"comments":[
{"id":338, "siteId": ...},
{"id":339, "siteId": ...},
...
{"id":363, "siteId": ...}
]}
http://cackle.me/api/3.0/comment/list.json?id=1&siteApiKey=123&accountApiKey=321&chan=/page4&commentId=0
{"comments":[
{"id":364, "siteId": ...},
{"id":365, "siteId": ...},
...
{"id":463, "siteId": ...}
]}
To track adds or changes (edit, delete, moderate, voting) Cackle comments, you must have a list of all channels (chan parameter) on your site and saved for each channel, time of last modification (modified parameter).
{"chans":[
{"id":101, "channel": ...},
{"id":102, "channel": ...},
...
{"id":216, "channel": ...}
]}
{"comments":[
{... "modified":"1432421378073"},
{... "modified":"1432447569166"},
...
{... "modified":"1432467294131"}
]}
In practice, implementing the algorithm, you typically create a separate table that stores the value [chan, modified]. When someone visits your website page, you can determine the channel (chan) and take modified (from [chan, modified] table), then you can call API. Also be sure to check the timer between requests, it needs to be at least 5 seconds.
Let your site http://mysite.com registered in Cackle with id 1, siteApiKey 123, accountApiKey 321 and gtModify 1455652041007 saved in the previous steps of getting channels list.
http://cackle.me/api/3.0/comment/chan/list.json?id=1&siteApiKey=123&accountApiKey=321>Modify=1455652041007
{"chans":[
{"id":1, "channel": '1', url: 'http://mysite.ru/page1',...},
{"id":2, "channel": '2', url: 'http://mysite.ru/page2',...},
So, on supposed site there are 2 pages and each include Cackle comments widget:
For the implementation of the algorithm must be created in the DB table with the channel and time of last modification [chan, modified]:
To insert the initial value (modified just select as the current time):
INSERT INTO chan_modified VALUES ('/page1', 1432421378073);
INSERT INTO chan_modified VALUES ('/page2', 1432421378073);
{"comments":[]}
because hardly anyone will have time to post or edit comments;{"comments":[
{"id":1, "siteId": ... "modified":"1432422582935"},
{"id":2, "siteId": ... "modified":"1432422739512"}
]}
UPDATE chan_modified SET modified = 1432422739512 WHERE chan = '/page1';
{"comments":[{"id":1, "siteId": ... "modified":"1432423183461"}}]}
UPDATE chan_modified SET modified = 1432423183461 WHERE chan = '/page1';
Sync lib on php - Cackle comments sync