Last active
August 29, 2015 13:58
-
-
Save lawrencejones/10305472 to your computer and use it in GitHub Desktop.
Example of how to pull data from new cate api.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo "Enter college login:" | |
read user | |
echo "Enter password:" | |
read -s pass; echo | |
creds="{\"user\":\"$user\",\"pass\":\"$pass\"}" | |
# Pull JSON { token: <token> } | |
tokenJson=$(curl -s -X POST -H "Content-Type: application/json" \ | |
-d $creds \ | |
-k 'https://doc-exams.herokuapp.com/authenticate') | |
# Extract token | |
token=$(coffee -e "console.log JSON.parse('$tokenJson').token") | |
echo "Got token! {$token}" | |
# Scrape dashboard | |
curl -X GET -H "Content-Type: application/json" \ | |
-H "Authorization: Bearer $token" \ | |
-k 'https://doc-exams.herokuapp.com/api/dashboard' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment