Creating a Drupal 7 Node Programmatically

<?php
/**
* Basic Node Creation Example for Drupal 7
*
* This example:
* - Assumes a standard Drupal 7 installation
* - Does not verify that the field values are correct
*/
 
$body_text = 'This is the body text I want entered with the node.';
 
 
$node = new stdClass();
 
$node->type = 'article';
 
node_object_prepare($node); //Creates default settings for the node of a type
 
$node->title    = 'Node Created Programmatically on ' . date('c');
 
$node->language = LANGUAGE_NONE; //String constant value for  "und"

/* If u have body text do the following below
  $node->body[$node->language][0]['value']   = $body_text;
  $node->body[$node->language][0]['summary'] = text_summary($body_text);
  $node->body[$node->language][0]['format']  = 'filtered_html';
  */
 
  //Define Custom CCK Fields here
 

$node->field_article_leave_type[$node->language][0]['value']=1;
 
$node->field_article_term[$node->language][0]['nid']=18;
 
$node->field_article_empref[$node->language][0]['uid']=2;
 
$node->field_article_numdays[$node->language][0]['value']=12.6;
 
$node->field_article_reason[$node->language][0]['value']="Yay...";   
 
$node->field_article_leave_scheme[$node->language][0]['nid']=16;
 
 
/* Do this if u do not have automatic url assignment
      $path = 'content/programmatically_created_node_' . date('YmdHis');
      $node->path = array('alias' => $path);
  */
 
 
node_save($node);

?>

--
Source:
http://www.group42.ca/creating_and_updating_nodes_programmatically_in_dr...
http://timonweb.com/how-programmatically-create-nodes-comments-and-taxon...