Add node programmatically including CCK field I'm pulling content from a web service and adding the nodes programmatically.  Here is my code so far:

foreach($content as $key =&gt; $value) {
    $node = new stdClass();
    $node-&gt;title =  $value['title'];
    $node-&gt;type = $field_map['type'][$value['type']];   // Use remote type as key in field map array to get local type
    node_object_prepare($node); // Sets some defaults. Invokes hook_prepare() and hook_node_prepare().
    $node-&gt;language = (isset($value['language'])) ? $value['language'] : LANGUAGE_NONE;
    $node-&gt;uid = $GLOBALS["user"]-&gt;uid;
    $node-&gt;status = $value['status']; //(1 or 0): published or not
    $node-&gt;promote = $value['promote']; //(1 or 0): promoted to front page
    $node-&gt;comment = $value['comment']; //2 = comments on, 1 = comments off
    $node-&gt;created = $value['created'];
    $node-&gt;changed = $value['changed'];
    $node-&gt;sticky = $value['sticky'];
    $node-&gt;translate = $value['translate'];
    $node-&gt;uuid = $value['uuid'];

    $node = node_submit($node); // Prepare node for saving
    node_save($node);
}


The example I'm following says to add cck fields like this:

// Entity reference field
    $node-&gt;field_customer_nid[$node-&gt;language][] = array(
        'target_id' =&gt; $form_state['values']['entity id'],
        'target_type' =&gt; 'node',
    );


I'm having difficulty because my CCK fields will vary depending on the content type that is being pulled form the web service. My fields are stored in the following format: 

$value['field_publish_date']


How could I go about adding the fields to my node?
First I would recommend using this type of structure for crating nodes progmatically

$node = new stdClass();
$node-&gt;type = 'story';
node_object_prepare($node);


If you're worried bout the content type being an issue use a switch statement by passing the content type in:

swicth($field_map['type'][$value['type']]){
  case 'story': //populate fields of story type;
    break;
  case 'page': //populate fields of page type;
    break;
}


Also if you are using a web service to import nodes I would suggest that you use the Feeds module http://drupal.org/project/feeds rather than creating them manually. I'm speaking from experience .