Use drupal_execute(). http://api.drupal.org/api/function/drupal_execute/6 On Thu, Feb 5, 2009 at 7:46 AM, Martin Stadler <martin@siarp.de> wrote:
Hi!
I'm working on a small curl-based script to add content to a drupal-6 site. Logging-in (getting cookie etc) works fine but when I try to add content I get a validation error. I guess it's about security. Is it at all possible to do what I'm trying? Is there documention how these form tokens actually work and what is required? I couldn't find that in the formAPI docs.
Here's the code:
# login curl http://localhost/USA08/user \ -F 'name=Martin' \ -F 'pass=pass' \ -F 'form_id=user_login' \ -F 'op=Log in' \ --output /Users/martin/response.html \ -s \ -c /tmp/curl-cookies.txt \ -b /tmp/curl-cookies.txt
# -> works: response.html says I'm logged-in
# add page curl http://localhost/USA08/node/add/page \ -F 'title=xyz' \ -F 'teaser_include=1' \ -F 'body=abc' \ -F 'format=1' \ -F 'changed=' \ -F 'form_id=page_node_form' \ -F 'log=' \ -F 'comment=0' \ -F 'name=Martin' \ -F 'date=' \ -F 'status=1' \ -F 'op=Save' \ --output /Users/martin/response2.html \ -s \ -c /tmp/curl-cookies.txt \ -b /tmp/curl-cookies.txt
# -> does not work: response2.html says 'Validation error, please try again. If this error persists, please contact the site administrator.'
Regards, Martin