#!/bin/bash
# 定义请求URL和数据
url="https://api-adservices.apple.com/api/v1"
data=""
output_file="requests_log.txt"
# 清空或创建输出文件
> "$output_file"
# 函数用于发送POST请求并记录日志
send_post_request() {
local request_number=$1
local response_code=$(curl -s -o /dev/null -w "Request %d: HTTP Code %{http_code}\n" -X POST -H "Content-Type: application/json" -d "$data" "$url")
echo "$response_code" >> "$output_file"
}
# 发送多个POST请求
for ((i=1; i<=5; i++)); do
send_post_request $i
done
echo "All requests have been logged to $output_file"
curl -X POST -i https://api-adservices.apple.com/api/v1 -H "Content-Type: application/json"
标签:脚本,code,请求,api,file,output,curl,POST From: https://www.cnblogs.com/maidongdong/p/18166255