Community

Create nodes with drupal_form_submit and node body fullhtml

$url = 'http://showmedo.com/videotutorials/video?name=4010000&fromSeriesID=401';
$html = file_get_html($url);
$code = $html->find('input[id=embed]', 0)->value;
module_load_include('inc', 'node', 'node.pages');

$node = (object) array(
'type' => 'article',
'language' => LANGUAGE_NONE
);
node_object_prepare($node);

$form_state = array();
$form_state['values']['title'] = 'drupal_form_submit';
$form_state['values']['name'] = 'admin';
$form_state['values']['op'] = t('Save');

$form_state['values']['body'][$node->language][0]['value'] = html_entity_decode($code, ENT_QUOTES);
$form_state['values']['body'][$node->language][0]['format'] = 'full_html';
drupal_form_submit("{$node->type}_node_form", $form_state, $node);

Comments

steely-eyed missleman

You sir, are a steely-eyed missleman. Thanks for this code. There are about 50 wrong examples on line.

nobody click here