Try it like this:
$comment = (object) array( 'nid' => $node_id, 'cid' => 0, 'pid' => 0, 'uid' => 1, 'mail' => '', 'is_anonymous' => 0, 'homepage' => '', 'status' => COMMENT_PUBLISHED, 'subject' => 'dsk subject', 'language' => LANGUAGE_NONE, 'comment_body' => array( LANGUAGE_NONE => array( 0 => array ( 'value' => 'aaa', 'format' => 'filtered_html' ) ) ), ); comment_submit($comment); comment_save($comment);
source share