Skip to content

Methods: Comments

Fabian Beiner edited this page Nov 15, 2017 · 2 revisions

“Comments” methods and examples

Get all comments

Method:

getAllComments($type, $typeId); // $type has to be "project" or "task"

// Alternatives:
getAllCommentsByTask($taskId);
getAllCommentsByProject($projectId);

Example:

$allComments = $Todoist->getAllComments('project', '2168427837');
print_r($allComments);

Array
(
    [0] => stdClass Object
        (
            [id] => 2214937295
            [project_id] => 2168427837
            [posted] => 2017-11-15T18:51:13Z
            [content] => Remember the budget!  :-o 
        )
)

Create a new comment

Method:

createComment($type, $typeId, $comment); // $type has to be "project" or "task"

// Alternatives:
createCommentForTask($taskId, $comment);
createCommentForProject($projectId, $comment);

Example:

$comment = $Todoist->createComment('project', '2168427837', 'But I got money!');
print_r($comment);

stdClass Object
(
    [id] => 2214942717
    [project_id] => 2168427837
    [posted] => 2017-11-15T19:17:50Z
    [content] => But I got money!
)

Get a comment

Method:

getComment($commentId);

Example:

$comment = $Todoist->getComment('2214942717');
print_r($comment);

stdClass Object
(
    [id] => 2214942717
    [project_id] => 2168427837
    [posted] => 2017-11-15T19:17:50Z
    [content] => But I got money!
)

Update a comment

Method:

updateComment($commentId, $content);

Example:

$success = $Todoist->updateComment('2214942717', 'OK OK. I got _some_ money.');
print_r($success);

1

Delete a comment

Method:

deleteComment($commentId);

Example:

$success = $Todoist->deleteComment('2214942717');
print_r($success);

1