Today I was using drupal_execute(), which is renamed drupal_form_submit() in Drupal 7. This is something I don't really like to do, favoring node_save() far more. In fact, if node_save() will work for what you can do, I would go ahead and use that instead. Even though drupal_execute() can technically accomplish the same thing, and it includes validation, it can be a pain to get working.
So I'm on the course, shooting par, and I'm getting this error:
warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'picasa_node_album_submit_handler' was given in C:\xampp\htdocs\openpublish\includes\form.inc on line 376.
Here's the offending code:
<?php module_load_include('inc', 'node', 'node.pages'); $form_state['values'] = array( 'picasa_album' => 'Crescent Hotel', 'nid' => 19114, 'uid' => 1, 'form_id' => 'picasa_node_album_add', ); drupal_execute('picasa_node_album_submit_handler', $form_state, $form_state); ?>
Basically, it's not finding the picasa_node_album_submit_handler function. "But whyyyyy???" I asked myself! Turns out it was a silly mistake, and you've probably already spotted it. This function is in the picasa_node_album module, and I didn't include the file in the script. Drupal doesn't include every module file for performance reasons, so if you want to reference something in a module, you have to include it. In fact, I included a file, but it was the wrong one (node.pages.inc), since that's what I was working with last time I used drupal_execute().
Change (or add) a single module_load line:
module_load_include('inc', 'picasa_node_album', 'picasa_node_album.pages');
Obviously your line would depend on which module you were using. The first parameter is the file extension. The second is the module name. The third is the file name minus the last extension.