今天遇到同事問我一個問題,如何在 curl 自動帶入 timestamp,在這邊做一下紀錄,也讓不知道的人學習一下,使用的方法如下:
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
timestamp=$(date +%s) | |
authorization=token | |
curl -v -H "Authorization: Bearer ${authorization}" -H 'content-type: application/x-www-form-urlencoded' -d "timestamp=${timestamp}" -X POST https://clarence.tw/api |
而有時候丟出去的 curl 又想要知道送出去的 request 有沒有正確,這時候就可以用下面的方法讓他把 request 顯示出來:
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
curl -v -H "Authorization: Bearer ${authorization}" -H 'content-type: application/x-www-form-urlencoded' -d "timestamp=${timestamp}" -X POST https://clarence.tw/api --trace-ascii /dev/stdout |
《AWS CDK 完全學習手冊:打造雲端基礎架構程式碼 IaC》
第 12 屆 iT 邦幫忙鐵人賽 DevOps 組冠的《用 CDK 定 義 AWS 架構》
第 11 屆 iT 邦幫忙鐵人賽《LINE bot 好好玩 30 天玩轉 LINE API》
一個熱愛分享的雲端工程師!