Programatically Create Nodes with Body and Custom Fields I need to write a module that will fetch remote content via an API and store it as nodes. These nodes have custom fields defined within the module. I have already accomplished this by modifying the Node Example Module.

I can add nodes via the admin end with all the custom fields, but when I'm trying to programatically create the nodes from hook_install(), the body and custom fields are not saving. 

The code for creating the fields is largely the same as the example I linked. Here's the function i'm using to create the nodes:

function sm_add_mashup_item_node($remoteId, $site, $text, $image, $time){

    $node = new stdClass();
    $node-&gt;type = 'rscg_mashup';
    node_object_prepare($node);

    $node-&gt;title = "My Awesome Title";
    $node-&gt;language = LANGUAGE_NONE;
    $node-&gt;created   = time();
    $node-&gt;timestamp = time();
    $node-&gt;changed   = time();

    $node-&gt;status = 1;
    //$node-&gt;uid = 1;
    $node-&gt;promote = 1;
    $node-&gt;sticky = 0;
    $node-&gt;format = 3;
    $node-&gt;language = 'en';
    $node-&gt;revision = 0;


    $node-&gt;body[$node-&gt;language][0]['format'] = 3;
    $node-&gt;body[$node-&gt;language][0]['summary'] = 'summary';
    $node-&gt;body[$node-&gt;language][0]['value'] = 'dfg sdgdfs gsdg sdfg sdfg sdfg sdfg sdfg sdfg sdgsdf';

    // Try to set your custom field
    $node-&gt;rscg_mashup_image_url[$node-&gt;language][0]['value'] = "Too many to count...";

    echo "\n Edited: \n";
    print_r(node_load(526));

    echo "\n Pre-Save: \n";
    print_r($node);


    $node = node_submit( $node );
    node_save($node);

    echo "\n Loaded: \n";
    print_r(node_load($node-&gt;nid));

    return;


I've tried countless variations of the above. 

Here is the debug output from the function:

https://gist.github.com/agroff/1c2c22920c20e3775b0d

This is a screenshot of the field list.
try using  like below

$node-&gt;body[LANGUAGE_NONE][0]['format'] = 3;
    $node-&gt;body[LANGUAGE_NONE][0]['summary'] = 'summary';
    $node-&gt;body[LANGUAGE_NONE][0]['value'] = 'dfg sdgdfs gsdg sdfg sdfg sdfg sdfg sdfg sdfg sdgsdf';

// Try to set your custom field
    $node-&gt;rscg_mashup_image_url[LANGUAGE_NONE][0]['value'] = "Too many to count...";