Improve bash implementation
This commit is contained in:
parent
24522ce8bb
commit
8deb13d824
1 changed files with 5 additions and 5 deletions
|
|
@ -1,12 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
# login and store cookies in 'cookies.txt'
|
||||
curl 'http://localhost/api.php/' --data "username=admin&password=admin" --cookie-jar cookies.txt --silent >/dev/null
|
||||
# login and store cookies in 'cookies.txt' AND retrieve the value of the XSRF token
|
||||
TOKEN=`curl 'http://localhost/api.php/' --data "username=admin&password=admin" --cookie-jar cookies.txt`
|
||||
|
||||
# retrieve the value of the 'XSRF-TOKEN' cookie
|
||||
TOKEN=`cat cookies.txt|grep XSRF-TOKEN|cut -f 7`
|
||||
# strip the double quotes from the variable (JSON decode)
|
||||
TOKEN=${TOKEN//\"/}
|
||||
|
||||
# set the 'XSRF-TOKEN' as the 'X-XSRF-Token' header AND send the cookies to the server
|
||||
# set the XSRF token as the 'X-XSRF-Token' header AND send the cookies to the server
|
||||
curl 'http://localhost/api.php/posts?include=categories,tags,comments&filter=id,eq,1' --header "X-XSRF-Token: $TOKEN" --cookie cookies.txt
|
||||
|
||||
# clean up
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue