Programmatically create an entity
The simpler approach is with the help of entity_metadata_wrapper(). 

$e = entity_create($entityType, array('type' =&gt; $bundleName));
$ew = entity_metadata_wrapper($entityType, $e);
$ew-&gt;field_name-&gt;set('value');
$ew-&gt;save();