# 注册时是否可以添加额外的API调用？

**URL:** https://meta.discourse.org/t/is-it-possible-to-add-extra-api-call-on-registration/182183
**Category:** Development
**Tags:** rest-api
**Created:** [2021年三月5日 13:16 UTC](https://meta.discourse.org/t/is-it-possible-to-add-extra-api-call-on-registration/182183 "2021-03-05T13:16:00Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Cyan\_Suntay](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cyan_suntay/32/206851_2.png) [@Cyan\_Suntay](https://meta.discourse.org/u/Cyan_Suntay)
#### Post date: [2021年三月5日 13:16 UTC](https://meta.discourse.org/t/is-it-possible-to-add-extra-api-call-on-registration/182183/1 "2021-03-05T13:16:00Z")

</div>

如何在注册、登录、登出和忘记密码时，在不使用 SSO 的情况下向我们的 API 添加额外调用？

示例：在注册时，当 Discourse 保存用户信息后，会触发一个 POST 请求到我们的 API，并将数据保存到我们的数据库中。登录时，Discourse 会向我们的 API 发送请求以验证用户信息；登出和忘记密码时也是如此。

希望能得到您的帮助，谢谢！

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [2021年三月5日 13:57 UTC](https://meta.discourse.org/t/is-it-possible-to-add-extra-api-call-on-registration/182183/2 "2021-03-05T13:57:34Z")

</div>

听起来您可能对我们的“Webhooks”系统感兴趣：

> [@Configure webhooks that trigger on Discourse events to integrate with external services](https://meta.discourse.org/t/setting-up-webhooks/49045):
>
> A webhook is a way to notify external services about changes on the internet. It’s easier to setup, manage and develop than a Discourse plugin. Though, it does require you to program a little bit or understand its technical details. In this #howto, I’ll set up webhook to power a Github bot for referencing pull request brought in a forum. We’ll want to see a new comment on Github pull request when a new post has a link to it. It’s a very simple process: Publish a new post. A webhook event happ…

---

<div class="post-metadata">

### Author: ![Cyan\_Suntay](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cyan_suntay/32/206851_2.png) [@Cyan\_Suntay](https://meta.discourse.org/u/Cyan_Suntay)
#### Post date: [2021年三月12日 14:47 UTC](https://meta.discourse.org/t/is-it-possible-to-add-extra-api-call-on-registration/182183/3 "2021-03-12T14:47:26Z")

</div>

@david 请求 URL 是我们用于创建学生的 POST 请求。我尝试过操作，但它总是返回如下内容：

 ![Screen Shot 2021-03-12 at 10.46.15 PM](https://global.discourse-cdn.com/meta/original/3X/2/0/2076c0fb1052917ebec83775e157abe50d25163b.png)

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [2021年三月12日 15:40 UTC](https://meta.discourse.org/t/is-it-possible-to-add-extra-api-call-on-registration/182183/4 "2021-03-12T15:40:43Z")

</div>

我们的 Webhook 会发送特定的负载。您需要配置您的 API 以理解该格式，或者使用其他服务（例如 Zapier）将格式转换为您 API 能够理解的格式。

---

<div class="post-metadata">

### Author: ![Cyan\_Suntay](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cyan_suntay/32/206851_2.png) [@Cyan\_Suntay](https://meta.discourse.org/u/Cyan_Suntay)
#### Post date: [2021年三月17日 06:29 UTC](https://meta.discourse.org/t/is-it-possible-to-add-extra-api-call-on-registration/182183/6 "2021-03-17T06:29:18Z")

</div>

@david 能否请教一下，为什么自定义用户字段（custom\_user\_fields）没有出现在截图右下角的表单数据中？谢谢。我需要获取 custom\_user\_field 并将其传递给我们的 API。目前我使用的是：

lastname: this.userFields[6]  
firstname: this.userFields[5]

因为提交后参数中显示的就是这些内容。

 ![Screen Shot 2021-03-17 at 2.27.25 PM](https://global.discourse-cdn.com/meta/original/3X/a/7/a7314c9ade80ef0fe2d51fe7b44e947745a764fb.png)
