twilio - 无法从 twilio 函数运行时客户端设置同步文档的 ttl

标签 twilio twilio-functions

我需要几分钟后自动删除我的 twilio 同步文档。

我遵循了 Runtime.getSync() 的文档,

which by the way seems to be introduced here https://www.twilio.com/docs/runtime/client and extended by the "Documents" section here https://www.twilio.com/docs/sync/api/documents using node.js examples,

it was so hard to piece it all toghether.

但我无法让 ttl 参数起作用

exports.handler = function(context, event, callback) {

    let sync = Runtime.getSync();
    let payload = {
        'greeting': "bonbon!"
    };
    let uniqueName = "test4";

    sync.documents.create({
        uniqueName: uniqueName,
        ttl: 5, //////////////////DOESN'T WORK!!!
        data: payload
    }).then(function(response) {
        console.log(response);
        callback(null, response);
    });
}

ttl 参数不会对文档的过期产生任何影响,甚至不会导致文档的参数“date_expires”(如 https://www.twilio.com/docs/sync/api/documents 示例中所示)反射(reflect)正确的值,实际上是 date_expires参数甚至没有出现在返回的 JSON 对象中:

{
_version: {
_domain: {
twilio: {
username: "xxxxxxxxxxxxxxxxxxxxxx",
password: "[Redacted]",
accountSid: "xxxxxxxxxxxxxxxxxxxxxx",
httpClient: { },
_sync: {
$ref: "$["_version"]["_domain"]"
}
},
baseUrl: "https://sync.twilio.com",
_v1: {
$ref: "$["_version"]"
}
},
_version: "v1"
},
sid: "xxxxxxxxxxxxxxxxxxxxxx",
uniqueName: "test4",
accountSid: "xxxxxxxxxxxxxxxxxxxxxx",
serviceSid: "xxxxxxxxxxxxxxxxxxxxxx",
url: "https://sync.twilio.com/v1/Services/xxxxxxxxxxxxxxxxxxxxxx/Documents/xxxxxxxxxxxxxxxxxxxxxx",
links: {
permissions: "https://sync.twilio.com/v1/Services/xxxxxxxxxxxxxxxxxxxxxx/Documents/xxxxxxxxxxxxxxxxxxxxxx/Permissions"
},
revision: "0",
data: {
greeting: "bonbon!"
},
dateCreated: "2018-09-19T03:30:24.000Z",
dateUpdated: "2018-09-19T03:30:24.000Z",
createdBy: "system",
_solution: {
serviceSid: "default",
sid: "xxxxxxxxxxxxxxxxxxxxxx"
}
}

有人有解释或解决方法吗? 预先非常感谢您

最佳答案

您使用哪个版本的 twilio?

https://www.twilio.com/console/runtime/functions/configure

如果小于3.6.10,则不支持ttl。

https://github.com/twilio/twilio-node/blob/master/CHANGES.md#2017-11-17-version-3100

[2017-11-17] Version 3.10.0

Sync

Add TTL support for Sync objects (breaking change)

最新版本是3.21.0。尝试一下。

关于twilio - 无法从 twilio 函数运行时客户端设置同步文档的 ttl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52397755/

相关文章:

android - Twilio 发送有关 android 问题的文本

twilio - 如何将处理从 Twilio 函数的调用传递回 Twilio Studio 流程?

twilio - 如何在 Twilio 函数中持久存储数据?

java - 无法在 Twilio 中发送短信

asp.net - Twilio 回调在我的 .NET 服务中不起作用

javascript - 如何在 Twilio Studio 的自定义函数中使用变量?

javascript - Twilio Nodejs - 如何调用 twilio 并收集输入的数字来调用另一个人

ruby-on-rails - 目录 : Polymorphic Controllers

ssl - 获取 "EIdHTTPProtocolException with message ' HTTP/1.1 400 BAD REQUEST'”异常