Import comments to Cackle

HTTP метод Endpoint Time limit Comments
POST http://cackle.me/api/3.0/comment/post.json 1 in every 5 seconds Import of comments from site page. Request data encoding UTF-8.

Request parameters:

Parameter Description Comments
id The widget ID You can get in the admin panel, on menu "Install" tab "CMS Platform" and choose WordPress.
siteApiKey The widget API key You can get in the admin panel, on menu "Install" tab "CMS Platform" and choose WordPress.
accountApiKey The account API key You can get in the admin panel, on menu "Install" tab "CMS Platform" and choose WordPress.
comments The comments list in JSON format

Example of parameter comments:

{
  "chan": "12345",
  "url": "http://site.com/post12345",
  "title": "My site | Post 12345",
  "comments": [{
    "id": "111",
    "msg": "Hello world!",
    "ip": "84.195.0.32",
    "status": "approved",
    "created": "1422820372367",
    "user": {
      "id": "808",
      "name": "Tom Cat",
      "email": "tomcat@example.org",
      "avatar": "//yourscr.com/40cc32af4753cdee62f527ef8ebe37df.png"
    }
  }, {
    "id": "888",
    "parent": "111",
    "msg": "Ok, ok, hello.",
    "media": "http://cackle.me/static/img/flat-comment.png http://cackle.me/static/img/flat-review.png",
    "ip": "40.105.4.195",
    "status": "approved",
    "created": "1425412776446",
    "name": "San",
    "email": "san@example.org"
  }]
}

Description of fields for the page:

Parameter Mandatory Description Comments
chan No ID to which will be attached comments on the page of your website By default, this url without Protocol and Domain. For example: for address http://example.org/page/12345, chan will be /page/12345.
If your site uses a CMS (WordPress, Joomla, Bitrix), chan is the post_ID from the database.
url Yes URL
title No Page title Usually taken from <title>...</title> tag on the page.

Description of fields comments:

Parameter Mandatory Description Comments
id Yes Comment ID Unique within a one widget.
parent No ID of the parent comment
msg Yes Comment text
media No Links to images List of links separated by spaces on image formats: png, jpg, gif.
ip Yes IP address From posted the comment.
status Yes Comment status Available: pending, approved, spam, deleted. The default is set to approved.
created Yes Creation date In milliseconds.
user Yes, if name, email absent Comment author Registered user of your site. If paid service "Single sign-on", then such user can log in under your account.
name No Anonymous name
email No Anonymous email

Import example in PHP with Curl lib

$comments=[];
$comments[]=Array(
    'id' => '111',
    'ip' => '111.111.111.111',
    'status' => 'approved',
    'msg'=> 'Привет мир!',
    'created' => '1422820372367',
    'user' => array(
    'id' => '808',
    'name' => 'Остап Бендер',
    'email' => 'ostap@example.org',
    'avatar' => 'http://cackle.me/static/img/logo.png'
        )
    );

$data = array(
    'chan' => '12345',
    'url' => 'http://cackle.me/test',
    'title' => 'Мой сайт | Товар 12345',
    'comments' => $comments);


function sendReviewsRequest($fields){
    $postfields = json_encode($fields);
    $curl_fields = array(
    'id' => 17216,
    'accountApiKey' => 'YrFno4qO3keCSOKGfjPh2SCbwkD3N6qp1NtCE66hA2IuxRtETTnmWlyyH7dOnVOa',
        'siteApiKey' => '97aCphfMrlnXIxxdYPFsF4dP4UrGc9oZVJLghOpDXneXgxIUnGdayyRzYj4az5TZ',
        'comments' => $postfields
    );
$curl=curl_init('http://cackle.me/api/3.0/comment/post.json');
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl,CURLOPT_POST,true);
curl_setopt($curl,CURLINFO_HEADER_OUT,true);
curl_setopt($curl,CURLOPT_POSTFIELDS,http_build_query($curl_fields));
$result = curl_exec($curl);
curl_close($curl);
print_r($result);
}
sendReviewsRequest($data);