0

Previously I'm using combination of cURL and sed to submit to Drupal 6 website. It was very flexible but it will works if I submit very frequently. If I want to submit 2 posts in one week, it will fail because of unique number generated in Drupal system over time.

I need to know any ways (drush or any other commands) that allow me submit new post easily

  • What kind of post? Are you trying to blog via command-line? Generate sample content? – Grayside Apr 10 '12 at 16:56
0

Drush has a php-script argument which will allow you to run a PHP file with any code in it. Since Drush performs a bootstrap and includes the usual files required at Drupal runtime before running your script, you have all of the Drupal API available to you in your custom script.

If you need to submit any arbitrary form you can pre-populate a $form_state array and then submit the values using drupal_execute (see its API documentation). Getting to know what values to pre-populate in $form_state can be tricky, but this line can help you out:

drupal_set_message('<pre>' . print_r($form_state, TRUE) . '</pre>';

Place this in the submit handler function for to the form you'd like to programatically submit and then run through the form once in your browser. Upon submitting that form, you should get a print out the $form_state structure that you would need to mimic. Be weary on live sites though, users will be able to see that debug message too!

If you're just needing to submitting nodes then you could even use node_save() directly which is a bit simpler. How to do this is detailed on another question, How to create nodes using node_save?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.