Facebook Messenger Platform:如何获取用户特定信息?
Facebook Messenger Platform: how to get user specific information?
我正在试用最近发布的 Facebook Messenger 平台,到目前为止一切顺利。一切正常,我能够创建一个 echo 机器人。
但我想知道如何识别开始在我的页面中聊天的用户。例如,当用户开始聊天时,我得到一个 PID 用户(页面特定的用户 ID)。
向 Facebook Graph 发出关注请求 API:
GET https://graph.facebook.com/v2.6/{PAGE_SPECIFIC_USER_ID}
我发现我可以只要求以下字段:first_name、last_name 和 profile_pic。
所以我的问题是,我怎样才能发现这个用户是否是我的业务页面的当前客户?是否有另一种查询更多信息的方法(如电子邮件和真实的 facebook 用户 ID)?
目前,没有办法做到这一点。最好的方法是提示用户在聊天中输入他们的信息,或者给他们一个 link 到移动登录页面,或者通过其他方式 link 将他们的帐户添加到聊天中。
Facebook 已更新 Messenger 平台 API (2016-07-01) and introduced a new feature called Account Linking. This can be used to identify a user who has created an account on your website via Facebook Login
and you can link the two accounts. Facebook login has its own set of permissions which can be used to get a lot more information via Facebook graph API. You can find the complete list here.
您可以使用 fb mq 库检索如下用户信息 https://github.com/conbus/fbmq
# this method will occur when a message received from user
@page.handle_message
def message_handler(event):
user_profile = page.get_user_profile(event.sender_id)
print(user_profile) #first_name, last_name, profile_pic, gender ...
Messenger Platform 2.0 引入"ID Matching API",这将解决问题。
https://developers.facebook.com/docs/messenger-platform/connecting-accounts
我正在试用最近发布的 Facebook Messenger 平台,到目前为止一切顺利。一切正常,我能够创建一个 echo 机器人。
但我想知道如何识别开始在我的页面中聊天的用户。例如,当用户开始聊天时,我得到一个 PID 用户(页面特定的用户 ID)。
向 Facebook Graph 发出关注请求 API:
GET https://graph.facebook.com/v2.6/{PAGE_SPECIFIC_USER_ID}
我发现我可以只要求以下字段:first_name、last_name 和 profile_pic。
所以我的问题是,我怎样才能发现这个用户是否是我的业务页面的当前客户?是否有另一种查询更多信息的方法(如电子邮件和真实的 facebook 用户 ID)?
目前,没有办法做到这一点。最好的方法是提示用户在聊天中输入他们的信息,或者给他们一个 link 到移动登录页面,或者通过其他方式 link 将他们的帐户添加到聊天中。
Facebook 已更新 Messenger 平台 API (2016-07-01) and introduced a new feature called Account Linking. This can be used to identify a user who has created an account on your website via Facebook Login
and you can link the two accounts. Facebook login has its own set of permissions which can be used to get a lot more information via Facebook graph API. You can find the complete list here.
您可以使用 fb mq 库检索如下用户信息 https://github.com/conbus/fbmq
# this method will occur when a message received from user
@page.handle_message
def message_handler(event):
user_profile = page.get_user_profile(event.sender_id)
print(user_profile) #first_name, last_name, profile_pic, gender ...
Messenger Platform 2.0 引入"ID Matching API",这将解决问题。 https://developers.facebook.com/docs/messenger-platform/connecting-accounts