蚂蚁cms火车头_了解无头CMS中的Webhooks

蚂蚁cms火车头

Modern development has transformed communication in numerous ways. As things evolve, the desire to communicate effectively with people sets.

现代发展以多种方式改变了沟通方式。 随着事情的发展,与人进行有效沟通的愿望开始了。

To attain such a communication demand we need, we need to find a way to make technologies talk to each other.

为了达到我们所需要的通信需求,我们需要找到一种使技术彼此对话的方法。

That’s where webhooks come into the picture.

这就是webhooks出现的地方。

Getting webhooks set up in a Headless CMS is much easier, faster, and cost-effective compared to setting it up via API approach.

与通过API方法进行设置相比,在Headless CMS中设置Webhooks更加容易,快捷且具有成本效益。

In this article, we would look at how we could set up webhooks using Agility CMS, a Headless CMS that’s is supercharged with JAMstack. It integrates seamlessly with modern, blazing-fast website frameworks and enables high-performance digital experiences.

在本文中,我们将研究如何使用Agility CMS来设置webhooks, Agility CMS是由JAMstack增强的无头CMS。 它与现代化,快速的网站框架无缝集成,并提供高性能的数字体验。

This article will be useful for you if;

如果有的话,这篇文章对您会很有用

  • you know the differences between an API and a Webhook, otherwise, check this 4 mins piece.

    你知道一个API和一个网络挂接之间的差异,否则,检查这个4分钟

  • you have built real-time applications that deliver data as an event happens or immediately using API’s.

    您已经建立了实时应用程序,可以在事件发生时或立即使用API​​传递数据。
  • you are already building webhooks with 3rd party applications, and you want to check out alternatives.

    您已经在使用第三方应用程序构建Webhooks,并且您想查看替代方法。

We will look at how to build a real-time, event-based simple app using Webhooks in Agility CMS.

我们将研究如何在Agility CMS中使用Webhooks构建基于事件的实时简单应用程序。

Let’s get to it!

让我们开始吧!

Note: This article assumes you’re comfortable with the basics of Node.Js.

注意 :本文假定您对Node.Js的基本知识感到满意。

什么是WebHooks? (What is WebHooks?)

Webhooks are automated messages that are sent each time an event happens. They have one unique mission: transmitting a message or data to a unique address or URL. Is a way for an app to provide other applications with real-time information. It delivers data as an event happens or almost immediately.

Webhook是每次事件发生时发送的自动消息。 他们有一个独特的任务:将消息或数据传输到唯一的地址或URL。 一种应用程序向其他应用程序提供实时信息的方式。 它在事件发生时或几乎立即发送数据。

何时使用Webhooks (When to Use Webhooks)

Webhooks usually acts as a messenger for smaller data. It helps to send and extracting real-time updates.

Webhooks通常充当较小数据的信使。 它有助于发送和提取实时更新。

One of the most suitable scenarios for using a webhook is when your app or platform requires a real-time feature and you don’t want to use an API, because you don’t want to get entangled with the setups and waste resources in the process. In such instances, a webhook framework will be most beneficial.

使用Webhook的最合适方案之一是您的应用程序或平台需要实时功能并且您不想使用API​​时,因为您不想纠结于设置和浪费资源中的资源。处理。 在这种情况下,webhook框架将是最有益的。

Another best use case for using a webhook is where an API isn’t provided or the available API isn’t best fit to act, a webhook could be used instead in such a situation.

使用Webhook的另一个最佳用例是未提供API或可用的API最不适合运行,在这种情况下可以使用Webhook代替。

Webhooks can be regarded as a perfect, and sometimes even essential complement to API-based application integration.

Webhooks可被视为对基于API的应用程序集成的完美,有时甚至是必不可少的补充。

This can be used to set up notification workflows in Slack, automatically redeploy static websites to Netlify, as well as a variety of other automation use cases.

这可用于在Slack中设置通知工作流,自动将静态网站重新部署到Netlify以及各种其他自动化用例。

Webhooks的好处 (Benefits of Webhooks)

  • It helps for clearing and managing a custom cache in an external system such as a website, mobile application, or database.

    它有助于清除和管理外部系统(例如网站,移动应用程序或数据库)中的自定义缓存。
  • It provides a way to sync content/data for integrations with third-party systems (i.e. Salesforce, Mailchimp, etc).

    它提供了一种同步内容/数据以与第三方系统(例如Salesforce,Mailchimp等)集成的方法。

  • It helps when building custom content workflows.

    在构建自定义内容工作流时会有所帮助。
  • Kick-off a CI/D pipeline to redeploy your website when content has been updated is possible with webhooks- this is often used for JAMstack sites that are built using static site generators.

    使用webhooks可以在更新内容后启动CI / D管道来重新部署您的网站-这通常用于使用静态网站生成器构建的JAMstack网站。

在无头CMS中使用webhooks (Using webhooks in a Headless CMS)

In this tutorial, we will see how to integrate webhooks in a headless CMS, and our choice would be Agility CMS.

在本教程中,我们将看到如何在无头CMS中集成webhooks,我们将选择Agility CMS

Agility CMS is a JAMStack focused Headless CMS with Page Management built-in. Faster to build, manage, and deploy. Agility CMS is a Content-First Headless CMS, allowing you to choose any programming language while also getting the flexibility, speed, and power that comes from lightweight APIs. From there, you could add features like Page Management, Ecommerce, Online Ticketing, and Search. Agility CMS becomes a complete Digital Experience Platform–saving time, removing limitations, and allowing for seamless experiences across all digital channels.

Agility CMS是一个内置JAMStack的无头CMS,内置页面管理。 更快地构建,管理和部署。 Agility CMS是Content-First Headless CMS,它使您可以选择任何编程语言,同时还可以获得轻量级API的灵活性,速度和功能。 从那里,您可以添加诸如页面管理,电子商务,在线票务和搜索之类的功能。 敏捷CMS成为一个完整的数字体验平台-节省时间,消除限制,并允许在所有数字渠道之间实现无缝体验。

使用Agility CMS实施Webhooks (Implementing Webhooks with Agility CMS)

This works by providing a list or URL endpoints to Agility CMS. Each time content changes in the CMS, Agility will notify each endpoint of the change and pass-on a message representing the exact change that occurred.

通过向Agility CMS提供列表或URL终结点来工作。 每次CMS中的内容更改时,Agility都会将更改通知给每个端点,并传递一条消息,表示发生的确切更改。

如何添加Webhook端点 (How to Add a Webhook Endpoint)

In order to add a webhook, you must have access to an Agility CMS instance with Content Fetch API enabled. To get started signup for free on Agility CMS.

为了添加Webhook,您必须有权访问启用了Content Fetch API的Agility CMS实例。 要免费开始使用Agility CMS进行注册。

  1. Next, In Agility CMS, navigate to Settings > Customization/Development > Webhooks.

    接下来,在Agility CMS中,导航到“设置”>“定制/开发”>“ Webhooks”

  1. Click Add (+) to add a webhook endpoint.

    单击添加(+)添加Webhook端点。

Image for post

3. Add your endpoint here

3.在此处添加端点

Image for post

In the Webhook details flyout, enter the Url endpoint that you want to send events to.

在“ Webhook详细信息”弹出框中,输入要将事件发送到的“ URL”端点。

For testing, we recommend using a free service such as https://requestbin.com which allows you to set up an endpoint and monitor the messages that get sent there.

对于测试,我们建议使用免费服务,例如https://requestbin.com ,该服务可让您设置终结点并监视从那里发送的消息。

Image for post
  1. After signing up/logging into their service, we get a Url we can use.

    注册/登录他们的服务后,我们将获得一个可以使用的网址

Image for post
  1. Next, select what type of Events this webhook should be subscribed to. You can optionally subscribe to all events (Publishes, Workflow Approvals, and Content Saves) or select only the type(s) you need.

    接下来,选择该Webhook应当订阅的事件类型。 您可以选择订阅所有事件(发布,工作流程批准和内容保存),或仅选择所需的类型。

  • Copy the URL given to you and paste it in your Agility Instance webhook page.

    复制提供给您的URL ,并将其粘贴到您的Agility Instance webhook页面中。

Image for post
  1. When you are ready, click the Send Test Payload button to test your webhook endpoint. This will generate a sample request to your defined endpoint Url and log the result.

    准备就绪后,单击发送测试有效负载按钮以测试您的Webhook端点。 这将向您定义的端点Url生成一个示例请求并记录结果。

Image for post
  1. If you created a request bin endpoint, you can verify the payload that was sent there.

    如果创建了请求容器终结点,则可以验证在此发送的有效负载。

Image for post
  1. When ready, click Save to save your webhook.

    准备就绪后,单击“ 保存”以保存您的Webhook。

有效负载详细信息 (Payload Details)

Page Events

页面事件

On Save:

保存时:

On Publish:

在发布时:

Content Events

内容事件

On Save:

保存时:

On Publish:

在发布时:

结论 (Conclusion)

In this article, we have seen how to seamlessly integrate webhooks in a Headless CMS using Agility CMS. You’d agree with me that it’s far much simpler compared to if you were using an API.

在本文中,我们已经看到了如何使用Agility CMS将Webhooks无缝集成到Headless CMS中。 您会同意我的观点,与使用API​​相比,它要简单得多。

I’d like to see what you come up with within the comment section, perhaps you’d prefer some another approach and why.

我想在注释部分中看到您的想法,也许您希望使用其他方法以及原因。

资源资源 (Resources)

翻译自: https://itnext.io/understanding-webhooks-in-headless-cms-71e62fdf365b

蚂蚁cms火车头

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值