Drupal 7 method The following code snippet can be used wherever there is a requirement to add a new node, being sure to replace <title> and with their actual values.
global $user;
$node = new stdClass();
$node->title = "<title>";
$node->type = "<node>";
node_object_prepare($node); // Sets some defaults. Invokes hook_prepare() and hook_node_prepare().