Created
March 14, 2012 17:28
-
-
Save ashee/2038065 to your computer and use it in GitHub Desktop.
Bash script to make AWS REST calls
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/bash | |
KEY='<get from AWS>' | |
ASSOC_ID='<get from AWS>' | |
TS=$(date -u "+%Y-%m-%dT%H:%M:%SZ" | sed 's/:/%3A/g') | |
RPARMS="AWSAccessKeyId=$KEY&AssociateTag=$ASSOC_ID&ItemId=0679722769&Operation=ItemLookup&ResponseGroup=ItemAttributes%2COffers%2CImages%2CReviews&Service=AWSECommerceService&Timestamp=$TS&Version=2009-01-06" | |
read -r -d '' REQ <<EOF | |
GET | |
webservices.amazon.com | |
/onca/xml | |
$RPARMS | |
EOF | |
# sign - hash_hmac | |
PK='<get from AWS>' # private key | |
SR=$(echo -n "$REQ" | openssl dgst -sha256 -hmac $PK -binary | openssl enc -base64 | sed 's/+/%2B/g;s/=/%3D/g;') | |
R=$(echo -n "http://webservices.amazon.com/onca/xml?$RPARMS&Signature=$SR") | |
curl "$R" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you very much! Good Luck!