title: Dynamically add a "Field Collection" in Drupal 7 by script?
body: <p>I want to add a "<a href="http://drupal.org/project/field_collection" rel="nofollow">field collection</a>" dynamically. But I'm not familiar with Field API or Entity API. New Entity API in Drupal is very poorly documented. </p>
  
  <p>Here is my code, until now:</p>
  
  <pre><code>$node = node_load(1);
  $field_collection_item = entity_create('field_collection_item', array('field_name' =&gt; 'field_book_text'));
  $field_collection_item-&gt;setHostEntity('node', $node);
  
  // Adding fields to field_collection
  
  $field_collection_item.save();
  </code></pre>
  
  <p>"Field Collection" module use function "<a href="http://api.drupal.org/api/drupal/includes--common.inc/function/entity_form_submit_build_entity/7" rel="nofollow">entity_form_submit_build_entity</a>" which I cannot use because there is no form in my case.</p>
  
  <p>I would appreciate if you can tell me how can I add fields?</p>