I have been playing around with the API from the command line so thought I'd put down my notes as a quick-start guide to accessing the API.
The first step that you will need to carry out is to login. To do so you can use the following command:
If the email and password are correct you should receive an authentication token to the email account specified in ${EMAIL}, the same as you would when you first log in to a machine. Note that if you have any special characters in your password (e.g. &) then these will need to be escaped using standard URL encoding.
Once you have this code you can send the confirmation request:
Again assuming that the code is correct you will now be set up to request data using the API. For example to obtain your profile:
The munging of the returned data via sed is to turn it in to standard JSON; feel free to skip this bit if you have a more forgiving parser.
The first step that you will need to carry out is to login. To do so you can use the following command:
Code:
EMAIL=YOUR_LOGIN_EMAIL_HERE
PASSWORD=YOUR_PASSWORD_HERE
USER_AGENT="Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D257"
curl -c cookies.txt -H "User-Agent: ${USER_AGENT}" -d email=${EMAIL} -d password="${PASSWORD}" https://companion.orerve.net/user/login
If the email and password are correct you should receive an authentication token to the email account specified in ${EMAIL}, the same as you would when you first log in to a machine. Note that if you have any special characters in your password (e.g. &) then these will need to be escaped using standard URL encoding.
Once you have this code you can send the confirmation request:
Code:
CODE=YOUR_CONFIRMATION_CODE_HERE
curl -b cookies.txt -c cookies.txt -H "User-Agent: ${USER_AGENT}" -d code=${CODE} https://companion.orerve.net/user/confirm
Again assuming that the code is correct you will now be set up to request data using the API. For example to obtain your profile:
Code:
curl -b cookies.txt -c cookies.txt -H "User-Agent: ${USER_AGENT}" https://companion.orerve.net/profile | sed -e 's/True/true/g' -e 's/False/false/g' -e s/\'/\"/g
The munging of the returned data via sed is to turn it in to standard JSON; feel free to skip this bit if you have a more forgiving parser.
Last edited: