Slack 的 chat.scheduleMessage API 不断抛出 Epoch 时间错误
Slack's chat.scheduleMessage API keeps throwing Epoch time error
我正在尝试使用 Slack API (https://api.slack.com/methods/chat.scheduleMessage) 中的 chat.scheduleMessage。但是,我不断收到错误 time_too_far
.
要求:
curl --location --request POST 'https://slack.com/api/chat.scheduleMessage' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer XXXX' \
--data-raw '{
"channel":"#test_channel",
"text":"Sample message",
"post_at":"1596647160000"
}'
回复:
{
"ok": false,
"error": "time_too_far",
"warning": "missing_charset",
"response_metadata": {
"warnings": [
"missing_charset"
]
}
}
根据开发者文档,它说 You will only be able to schedule a message up to 120 days into the future. If you specify a post_at timestamp beyond this limit, you’ll receive a time_too_far error response.
。但是,在这种情况下,我只是安排明天的消息。
不确定我是否遗漏了什么。
您提供的时间戳是 JavaScript timestamp (milliseconds since epoch), while Slack's scheduled message API takes a Unix timestamp(自纪元以来的秒数)。除以 1000 应该可以修复错误。
我正在尝试使用 Slack API (https://api.slack.com/methods/chat.scheduleMessage) 中的 chat.scheduleMessage。但是,我不断收到错误 time_too_far
.
要求:
curl --location --request POST 'https://slack.com/api/chat.scheduleMessage' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer XXXX' \
--data-raw '{
"channel":"#test_channel",
"text":"Sample message",
"post_at":"1596647160000"
}'
回复:
{
"ok": false,
"error": "time_too_far",
"warning": "missing_charset",
"response_metadata": {
"warnings": [
"missing_charset"
]
}
}
根据开发者文档,它说 You will only be able to schedule a message up to 120 days into the future. If you specify a post_at timestamp beyond this limit, you’ll receive a time_too_far error response.
。但是,在这种情况下,我只是安排明天的消息。
不确定我是否遗漏了什么。
您提供的时间戳是 JavaScript timestamp (milliseconds since epoch), while Slack's scheduled message API takes a Unix timestamp(自纪元以来的秒数)。除以 1000 应该可以修复错误。