To add a node to an organic group programmatically this code absolutely works as of May 15th 2013. There are a lot of articles on the web I've read with either incorrect code or outdated code:
$entity = node_load($nid); $values = array('entity_type' => 'node', 'entity' => $entity, 'field_name' => 'og_group_ref', 'state' => 1); og_group('node', $row->gid, $values); node_save($node);