You are here

Curl example


# login
curl http://localhost/drupal/?q=user \
-s \
-c cookie.txt \
-b cookie.txt \
-F 'name=user' \
-F 'pass=pass' \
-F 'form_id=user_login' \
-F 'op=Log in' \
--output response0.html
#
# get form
curl http://localhost/drupal/?q=node/add/page \
-s \
-c cookie.txt \
-b cookie.txt \
--output response1.html
# -> extract token from response1.html (/edit-page-node-form-form-token" *value="([^"]*)"/)
#
# add page
# -> use extracted token
curl http://localhost/drupal/?q=node/add/page \
-s \
-c cookie.txt \
-b cookie.txt \
-F 'title=xyz' \
-F 'body=abc' \
-F 'form_id=page_node_form' \
-F 'form_token=63fe773e820d2a4565720ab3bd0fc991' \
-F 'status=1' \
-F 'revision=1' \
-F 'op=Save' \
--output response2.html

Topic: