When there click on the start link and you will see
"To perform this request with curl, use:
curl -i -X GET "https://api.hashblue.com/account" \
-H "Authorization: OAuth v9rty6aBqtY5Leru0ior6bhu8MAwf79m" \
-H "Accept: application/json"
"
The OAuth token is the value you will need to enter in the script below:
#!/bin/ksh
OAuth=v9rty6aBqtY5Leru0ior6bhu8MAwf79m
i=1
OUTPUT=/Users/cranie/hash-blue/messages.${i}.json
URL="https://api.hashblue.com/messages?since=2005-01-01T00:30Z"
curl -i -X GET "${URL}" -H "Authorization: OAuth ${OAuth}" -H "Accept: application/json" >> ${OUTPUT}
URL=`tail -1 ${OUTPUT} | sed -e 's/.*next_page_uri\"\:\"//g' -e 's/\"..*//g'`
i=$(( ${i} + 1 ))
OUTPUT=/Users/cranie/hash-blue/messages.${i}.json
while [ ${URL} != "" ]
do
curl -i -X GET "${URL}" -H "Authorization: OAuth ${OAuth}" -H "Accept: application/json" >> ${OUTPUT}
URL=`tail -1 ${OUTPUT} | sed -e 's/.*next_page_uri\"\:\"//g' -e 's/\"..*//g'`
i=$(( ${i} + 1 ))
OUTPUT=/Users/cranie/hash-blue/messages.${i}.json
doneThen run. When done you will have your messages in json format in like so:
cranie:hash-blue cranie$ ls -l total 1744 -rwxr-xr-x 1 cranie staff 723 23 Aug 21:37 GetMessages.sh -rw-r--r-- 1 cranie staff 23744 23 Aug 21:38 messages.1.json -rw-r--r-- 1 cranie staff 23983 23 Aug 21:40 messages.10.json -rw-r--r-- 1 cranie staff 24515 23 Aug 21:40 messages.11.json -rw-r--r-- 1 cranie staff 24243 23 Aug 21:41 messages.12.json -rw-r--r-- 1 cranie staff 24413 23 Aug 21:41 messages.13.json -rw-r--r-- 1 cranie staff 24063 23 Aug 21:41 messages.14.json -rw-r--r-- 1 cranie staff 24141 23 Aug 21:41 messages.15.json -rw-r--r-- 1 cranie staff 25327 23 Aug 21:42 messages.16.json
