Use drupal_execute().<br><br><a href="http://api.drupal.org/api/function/drupal_execute/6">http://api.drupal.org/api/function/drupal_execute/6</a><br><br><br><div class="gmail_quote">On Thu, Feb 5, 2009 at 7:46 AM, Martin Stadler <span dir="ltr"><<a href="mailto:martin@siarp.de">martin@siarp.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi!<br>
<br>
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.<br>
<br>
Here's the code:<br>
<br>
<br>
# login<br>
curl <a href="http://localhost/USA08/user" target="_blank">http://localhost/USA08/user</a> \<br>
-F 'name=Martin' \<br>
-F 'pass=pass' \<br>
-F 'form_id=user_login' \<br>
-F 'op=Log in' \<br>
--output /Users/martin/response.html \<br>
-s \<br>
-c /tmp/curl-cookies.txt \<br>
-b /tmp/curl-cookies.txt<br>
<br>
# -> works: response.html says I'm logged-in<br>
<br>
# add page<br>
curl <a href="http://localhost/USA08/node/add/page" target="_blank">http://localhost/USA08/node/add/page</a> \<br>
-F 'title=xyz' \<br>
-F 'teaser_include=1' \<br>
-F 'body=abc' \<br>
-F 'format=1' \<br>
-F 'changed=' \<br>
-F 'form_id=page_node_form' \<br>
-F 'log=' \<br>
-F 'comment=0' \<br>
-F 'name=Martin' \<br>
-F 'date=' \<br>
-F 'status=1' \<br>
-F 'op=Save' \<br>
--output /Users/martin/response2.html \<br>
-s \<br>
-c /tmp/curl-cookies.txt \<br>
-b /tmp/curl-cookies.txt<br>
<br>
# -> does not work: response2.html says 'Validation error, please try again. If this error persists, please contact the site administrator.'<br>
<br>
Regards,<br><font color="#888888">
Martin<br>
<br>
</font></blockquote></div><br>