I used this post and this post to get started but I was trying to use only the entity API.
Here is my code. So far the node creation works but I'm not able to save the node under the correct tid.
global $user;
$properties = array(
'type' => 'forum',
'uid' => $user->uid,
'status' => 0
);
$entity = entity_create('node', $properties);
$wrapper = entity_metadata_wrapper('node', $entity);
$wrapper->title = "My new forum topic";
$terms = taxonomy_get_term_by_name ('General discussion','forums');
//$wrapper->taxonomy = $terms; //Doesnt work
//$wrapper->forum_tid = $terms->tid; //Doesnt work
//$wrapper->taxonomy_forums = $terms->tid; //Doesnt work
$wrapper->save();
$wrapper->taxonomy_forums = $terms->tid
or$wrapper->taxonomy_forums->set($terms->tid);
should work fine, assuming$terms->tid
is valid