目录:
一、GET请求
1、脚本代码
执行脚本的命令:
bash wps-41.sh

#/bin/bash
appid=xxxxxxxxxx
appkey=xxxxxxxxxx
# 定义一个函数来发送curl请求
http_request() {
method=$1 # 获取方法类型,如GET或POST
url=$2 # 获取请求的URL
urlPath=$3
data=$4 # 获取传递的数据(仅用于POST)
md5sum_value=$(echo -n "$data" | md5sum | awk '{print $1}')
Date=$(date -u '+%a, %d %b %Y %T GMT')
authorization=$(hmac-sha256 "WPS-4" $method $urlPath "application/json" "$Date")
printf -v XAuth "WPS-4 %s:%s" "$appid" "$authorization"
# 发送请求
curl -vvvv -s -X $method "$url$urlPath" -H "Content-Type: application/json" -H "Wps-Docs-Date: $Date" -H "Wps-Docs-Authorization: $XAuth" -d "$data"
}
#body 使用暂时不用考虑
sha1_string() {
echo -n "$1$2$3$4$5" | sha256sum | awk '{print $1}'
}
hmac-sha256() {
echo -n "$1$2$3$4$5" | openssl dgst -sha256 -hmac "$appkey" | awk '{print $2}'
}
response=$(http_request "GET" "https://lxxxxxx.wpseco.cn/open" "/api/preview/v1/files/d2ce22415ba94071a21016a64a23996e/link?type=f" ""

最低0.47元/天 解锁文章
1761

被折叠的 条评论
为什么被折叠?



