我正在构建一个平台来创建和组织社交媒体帖子,并通过将它们发布到Facebook上。我已经设置了获得所需访问令牌的逻辑,并立即将帖子发布到Facebook页面上,运行良好。然而,如果我试图安排发布,我总是会得到错误。
"(#100)指定的计划发布时间无效“。
我使用POST请求https://graph.facebook.com/page_id/feed来使用以下参数查询Facebook
access_token=...
message=Test
published=false
scheduled_publish_time=time计算UNIX时间戳的方法是
const minutes = 15;
const time = new Date().getTime() + minutes * 60 * 1000;考虑到我在特性中安排了15分钟的帖子,我假设我已经考虑到了所有必要的需求(https://developers.facebook.com/docs/graph-api/using-graph-api/common-scenarios#scheduledposts)。
编辑
正如@04FS所指出的,您需要以秒而不是毫秒为单位给出时间戳。因此,以下几点解决了我的问题
const minutes = 15;
const time = Math.round((new Date().getTime() + minutes * 60 * 1000) / 1000);发布于 2019-05-16 13:58:47
const minutes = 15;
const time = new Date().getTime() + minutes * 60 * 1000;JavaScript的Date对象以毫秒为单位工作,而不是秒。您的JS代码当前的值大约为1558015867708,这将是unix时间戳07/23/51341 @ 1:28am (UTC)。
API需要一个正确的unix时间戳(以秒为单位),而不是毫秒。
https://stackoverflow.com/questions/56170141
复制相似问题