Skip to content

Instantly share code, notes, and snippets.

@padwasabimasala
Last active August 29, 2015 14:13
Show Gist options
  • Save padwasabimasala/e58f0535b4c014e29207 to your computer and use it in GitHub Desktop.
Save padwasabimasala/e58f0535b4c014e29207 to your computer and use it in GitHub Desktop.
test vision wall feed
HOST=${1-https://vision.appreciatehub.com}
API=$HOST/api
if test -z $CLIENT_ID || test -z $CLIENT_SECRET; then
echo CLIENT_ID or CLIENT_SECRET not set in the ENV >&2
exit 1
fi
parse() {
jq $1 |sed -e 's/"//g'
}
echo $(tput sgr0)
echo -n
# Get the auth endpoint
RootJson=$(curl $API 2>/dev/null)
AuthUrl=$(echo $RootJson |parse '.oauth.href')
echo AuthUrl $AuthUrl
# Get a token
TokenJson=$(curl \
-H 'content-type: application/json' \
$AuthUrl/token \
-X POST \
-d "{\"client_id\": \"$CLIENT_ID\",
\"client_secret\": \"$CLIENT_SECRET\",
\"grant_type\": \"client_credentials\",
\"scope\": \"recognition_events\"}" \
2>/dev/null
)
Token=$(echo $TokenJson |parse .access_token)
echo Token $Token
# Get the wall endpoint
AuthedRootJson=$(curl $API -H "Authorization: Bearer $Token" 2>/dev/null)
WallUrl=$(echo $AuthedRootJson |parse '.wall.href')
echo WallUrl $WallUrl
WallJson=$(curl $WallUrl -H "Authorization: Bearer $Token" 2>/dev/null)
echo $WallJson |jq '.'
FeedsUrl=$(echo $WallJson |parse '.feeds.href')
echo FeedsUrl $FeedsUrl
FeedsJson=$(curl $FeedsUrl -H "Authorization: Bearer $Token" 2>/dev/null)
echo $FeedsJson |jq '.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment