Can't add taxonomy term to node?
You can do it like this: 


if ($foo = taxonomy_get_term_by_name($term_name)) {
      $foo_keys = array_keys($foo);
      $node->your_taxonomy_field_name[LANGUAGE_NONE][]['tid'] = $foo_keys[0];  
    }
    else {
      $node->your_taxonomy_field_name[LANGUAGE_NONE][] = array (
        'vid' => 1,
        'tid' => 'autocreate',
        'name' => $term_name,
        'vocabulary_machine_name' => 'machine_name'
      );