Skip to content

Instantly share code, notes, and snippets.

@swenson
Created February 25, 2014 03:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swenson/9202022 to your computer and use it in GitHub Desktop.
Save swenson/9202022 to your computer and use it in GitHub Desktop.
#!/bin/bash
ENDPOINT="api.sandbox.paypal.com"
CLIENT_ID=""
SECRET=""
#ENDPOINT="api.paypal.com"
#CLIENT_ID=""
#SECRET=""
TOKEN=`curl -s https://${ENDPOINT}/v1/oauth2/token \
-H "Accept: application/json" \
-H "Accept-Language: en_US" \
-u "${CLIENT_ID}:${SECRET}" \
-d "grant_type=client_credentials" | jsonpp | grep -e "access_token" | cut -d':' -f2 | cut -d'"' -f2`
COUNT=`curl -s "https://${ENDPOINT}/v1/payments/payment?start_time=2001-01-01T00:00:00Z" \
-H 'Content-Type:application/json' \
-H "Authorization:Bearer ${TOKEN}"`
echo $COUNT
if [[ -e count.txt ]]; then
OLD_COUNT=`cat count.txt`
else
OLD_COUNT=''
fi
if [[ "$COUNT" != "$OLD_COUNT" ]]; then
echo "#00ff00"
else
echo "#000000"
fi
echo $COUNT > count.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment