Save comment dynamically I've made my own module to add commenting to a node (it opens modally in a colorbox - really nice). The form works great, but how do I save the comment?

I know it's got to be done using comment_save. But, as usual, drupal.org is great at showing the code for the function without giving an example...

Has anyone done this before? 

I'm guessing it's something like: 

$comment = new stdClass();

$comment-&gt;nid = $the_node_the_comment_is_for;
$comment-&gt;title = $my_comment_title;
$comment-&gt;body = $my_comment_body;

comment_save($comment);
Yes you can save comment dynamically using comment_save() function, a working example is given below

&lt;?php

$comment = new stdClass();

$comment-&gt;nid = 28; // nid of a node you want to attach a comment to
$comment-&gt;cid = 0; // leave it as is
$comment-&gt;pid = 0; // parent comment id, 0 if none 
$comment-&gt;uid = 1; // user's id, who left the comment
$comment-&gt;mail = 'email@example.com'; // user's email
$comment-&gt;name = 'User name'; // If user is authenticated you can omit this field, it will be auto-populated, if the user is anonymous and you want to name him somehow, input his name here
$comment-&gt;thread = '01/'; // OPTIONAL. If you need comments to be threaded you can fill this value. Otherwise omit it.
$comment-&gt;hostname = '127.0.01' ;// OPTIONAL. You can log poster's ip here
$comment-&gt;created = time(); // OPTIONAL. You can set any time you want here. Useful for backdated comments creation.
$comment-&gt;is_anonymous = 0; // leave it as is
$comment-&gt;homepage = ''; // you can add homepage URL here
$comment-&gt;status = COMMENT_PUBLISHED; // We auto-publish this comment
$comment-&gt;language = LANGUAGE_NONE; // The same as for a node
$comment-&gt;subject = 'Comment subject'; 
$comment-&gt;comment_body[$comment-&gt;language][0]['value'] = 'Comment body text'; // Everything here is pretty much like with a node
$comment-&gt;comment_body[$comment-&gt;language][0]['format'] = 'filtered_html'; 
$comment-&gt;field_custom_field_name[LANGUAGE_NONE][0]['value'] = 'Some value'; // OPTIONAL. If your comment has a custom field attached it can added as simple as this // preparing a comment for a save

comment_submit($comment); // saving a comment
comment_save($comment);
?&gt;