我正在编写我与Zapier的第一个API集成。我已经使用REST钩子创建了一个触发器,该触发器可以正确触发,但我不确定如何确定用户在Zapier中选择的触发器选项。具体来说,我允许他们选择一个登录页面,除非我知道他们想要激活哪个登录页面,否则我不知道如何处理它,但我在订阅Zapier时得到的结果是:
{ "subscription_url":"https://hooks.zapier.com/hooks/standard/102653/94703dc5c31247c4acb8b82977fd08dc/","target_url":"https://hooks.zapier.com/hooks/standard/102653/94703dc5c31247c4acb8b82977fd08dc/","event":"landing_page_submitted“}
我知道我可能遗漏了什么。我应该在触发器下拉菜单的某处找到所选的选项吗?或者我需要在Zapier端配置一些东西来处理它?
发布于 2019-09-02 20:39:49
我是David,来自Zapier平台团队。
如果我没理解错的话,您只需要从inputData
传入数据。
在你的钩子订阅中,有一个地方可以传递数据(比如上面的"event"
)。您可以添加类似于landing_page: bundle.inputData.landing_page
的内容。这里有一个更完整的示例here:
const subscribeHook = (z, bundle) => {
// bundle.targetUrl has the Hook URL this app should call when a recipe is created.
const data = {
url: bundle.targetUrl,
style: bundle.inputData.style
};
// You can build requests and our client will helpfully inject all the variables
// you need to complete. You can also register middleware to control this.
const options = {
url: 'http://57b20fb546b57d1100a3c405.mockapi.io/api/hooks',
method: 'POST',
body: JSON.stringify(data)
};
// You may return a promise or a normal data structure from any perform method.
return z.request(options)
.then((response) => JSON.parse(response.content));
};
https://stackoverflow.com/questions/57731277
复制