認証方法が複数ある:
エラーの時は .status があるので、エラー時だけjsonを表示したい場合。
cat error.json | jq -r "select(.status!=null) | @text" {"code":20003,"detail":"Your AccountSid or AuthToken was incorrect.","message":"Authentication Error - No password provided","more_info":"https://www.twilio.com/docs/errors/20003","status":401}
例: 当日のsmsの使用量を取得
account_sid=AC**** api_sid=SK**** category=sms # sms,calls,totalprice date=$(date +%Y-%m-%d) read -sp "apikey: " apikey curl -s -G https://api.twilio.com/2010-04-01/Accounts/$account_sid/Usage/Records/Daily.json \ -d "Category=$category" \ -d "StartDate=$date" \ -d "EndDate=$date" \ -u "$api_sid:$apikey" > Daily.$date.json
Read multiple UsageRecord resources
curl -s -G https://api.twilio.com/2010-04-01/Accounts/$account_sid/Usage/Records.json \ -d "StartDate=$date" \ -d "EndDate=$date" \ -u "$api_sid:$apikey" > Records.$date.json # jqで、全カテゴリとCountのみ取得 cat Records.$date.json | jq '.usage_records[] | [.category, .count]' | less