且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MessengerExtensions:如何通过信使向用户发送消息?

更新时间:2023-12-04 09:12:28

您可以进行服务器往返.

You can do a server round trip.

关闭 webview 有一个成功回调.您可以对您的网络服务之一进行 api 调用.您将页面范围的用户 ID 传递给此服务.然后一旦知道用户是谁,就可以使用 发送 API

closing webview has a success callback. You can make an api call to one of your webservice. You pass the page scoped user id to this service. Then once you know who the user is, you can send the message to the user using the Send API

另一种方法.如果您要求用户登录 webview,您可以使用 登录按钮.在这种情况下,一旦用户被重定向到 Messenger(即关闭 webview 后),您将收到一个 webhook 事件,并使用它可以将消息发送给用户.

Another approach. In case you are asking the user to login in webview, you can use the login button. In this case once the user is redirected to the messenger (i.e. after webview is closed) you will get a webhook event and using that you can send the message to the user.