API调用-Shell


2023年6月4日 14:15     admin

  1. #!/bin/bash
  2. accountsid="a4462df20ed7f530be9f61ad4e65252e"
  3. authtoken="7748bffdd06f44cbd584919491b0ea46"
  4. timestamp=$(date +%Y%m%d%H%M%S)
  5. echo $timestamp
  6. timess=$(date +%s)001
  7. echo $timess
  8. sig=`echo -n ${accountsid}${authtoken}${timestamp} |openssl dgst -sha1 |awk '{print $2}'`
  9. Authorization=`echo -n ${accountsid}:${timestamp} |openssl enc -base64`
  10. echo $Authorization
  11. Accept="application/json;charset=utf-8"
  12. Content_Type="application/json;charset=utf-8"
  13. Content_Length="131"
  14. appid="2f2f6da928b74959a4c894ceb1cba497"
  15. templateID="20001"
  16. url="http://192.168.110.145:10000/api/v1.0.0/voice/notify?sig=${sig}";
  17. date="{\"info\":{\"appID\":\"$appid\"},\"timestamp\":\"$timess\",\"data\":\"abc123\",\"subject\":{\"playTimes\":10,\"params\":[\"$2\"],\"called\":\"$1\",\"calledDisplay\":\"10001\",\"templateID\":\"$templateID\"}}"
  18. echo $date
  19. recust=`curl -H "Authorization: $Authorization" -H "Accept: $Accept" -H "Content-Type: $Accept" -H "Content-Length: ${#date}" -s -X POST --data $date $url`
  20. echo $recust