PHP code example of benyazi / cmtt-php

1. Go to this page and download the library: Download benyazi/cmtt-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

benyazi / cmtt-php example snippets


$client = new \Benyazi\CmttPhp\Api(\Benyazi\CmttPhp\Api::TJOURNAL);

$userId = 27100;
$userData = $client->getUser($userId);


$client = new \Benyazi\CmttPhp\Api(\Benyazi\CmttPhp\Api::TJOURNAL, 'TOKEN_FOR_USER');

//ID статьи
$contentId = 99328;
//Текст комментария
$commentText = "Раз-раз, проверка";
$commentData = $client->sendComment($contentId, $commentText);

//ID комментария, на который отправляется ответ
$replyTo = 2472464;
$commentText = "Раз-раз, проверка, ответа на другой комментарий";
$commentData = $client->sendComment($contentId, $commentText, $replyTo);

//ID статьи или комментария
$commentId = 2471797;
$commentData = $client->like($commentId, \Benyazi\CmttPhp\Api::LIKE_TYPE_COMMENT);

//ID статьи или комментария для дислайка
$commentId = 2471797;
$commentData = $client->like($commentId, \Benyazi\CmttPhp\Api::LIKE_TYPE_COMMENT, \Benyazi\CmttPhp\Api::SIGN_DISLIKE);

$client = new \Benyazi\CmttPhp\Api(\Benyazi\CmttPhp\Api::TJOURNAL, 'TOKEN_FOR_USER');

//ID статьи или комментария
$commentId = 2471797;
//ID site
$siteId = 1000;
$commentData = $client->authPossess($siteId)->like($commentId, \Benyazi\CmttPhp\Api::LIKE_TYPE_COMMENT);

$client->logoutPossess();

php composer.phar 
js
"benyazi/cmtt-php": "dev-master"