来自Facebook Messenger机器人对话的API身份验证 [英] API authentication from a facebook messenger bot conversation

查看:238
本文介绍了来自Facebook Messenger机器人对话的API身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从与Facebook Messenger平台上的漫游器进行对话时,使用外部API进行身份验证的最佳方法是什么?

What is the best way to authenticate with an external API from a conversation with a bot on the facebook messenger platform?

举一个广泛的例子,我希望我的机器人的用户可以在自己的外部网站配置文件中创建项目.有没有一种方法可以从用户那里获取登录信息,或者将我的机器人连接到外部网站,而无需用户将其用户名和密码明确发送给机器人的消息?

For a broad example, I would like a user of my bot to create items on their own profiles of an external website. Is there a way to get login information from the user, or connect my bot to the external website, without the user explicitly sending a message to the bot with their username and password?

我在 User Profile API的文档中找到的内容:

您可以使用用户个人资料API中该人的姓名或个人资料照片来个性化对话.为了获取此信息,请向 https://graph.facebook.com/v2发出GET请求. 6/?fields =名字,姓氏,profile_pic& access_token =.在Send API参考中阅读更多详细信息.

You can personalize the conversation using the person's name or profile pic from the User Profile API. In order to get this information, make a GET request to https://graph.facebook.com/v2.6/?fields=first_name,last_name,profile_pic&access_token=. Read more details in the Send API reference.

这不是我想要的,但可以帮上忙.这是来自文档的更多信息:

This isn't quite what I'm looking for but it helps. Here's more info from the docs:

用户个人资料API

User Profile API

请求

curl -X GET "https://graph.facebook.com/v2.6/<USER_ID>?fields=first_name,last_name,profile_pic&access_token=<PAGE_ACCESS_TOKEN>"

响应

{ "first_name": "Peter", "last_name": "Chang", "profile_pic": "https://fbcdn-profile-a.akamaihd.net/hprofile...70ec9c19b18" }

{ "first_name": "Peter", "last_name": "Chang", "profile_pic": "https://fbcdn-profile-a.akamaihd.net/hprofile...70ec9c19b18" }

推荐答案

这取决于它们的进入方式.

It depends how they come in.

  1. 如果他们来自您的网站,则可以使用他们帐户中的发送到Messengee"按钮.使用传递参数将您的帐户链接到用户线程. 以下是文档的摘录:
  1. If they come from your website, you can use the Send to Messengee button from within their account. Use the pass through param to link your account to the user thread. Here's an excerpt from the documentation:

该插件采用您定义的传递参数.该参数通过回调发送回给您.您可以使用此链接将身份验证事件链接到个人和/或交易.例如,某人可以输入特定交易的在线流程,然后单击发送至信使"按钮.您可以传递数据以了解哪个用户和事务与身份验证事件相关联.您应该对该参数进行编码和加密.

The plugin takes in a pass-through parameter defined by you. This parameter is sent back to you via a callback. You can use this to link the authentication event to a person and/or transaction. For example, a person may enter an online flow for a specific transaction and click the Send-to-Messenger button. You can pass in data to know which user and transaction was tied to the authentication event. You should encode and encrypt this parameter.

  1. 如果它们直接进入您的机器人,则您必须在对话中向他们显示某种登录名(您的登录名).这将在指向移动Web URL的链接中发生.

这篇关于来自Facebook Messenger机器人对话的API身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆