Facebook Messenger Platform: how to get user specific information?

*爱你&永不变心* 提交于 2020-01-12 07:36:08

问题


I'm trying the recent released Facebook Messenger Platform and so far so good. Everything worked well and I was able to create a echo bot.

But I'm wondering how I could identify this user that started chatting in my page. For example, when a user started chatting I get a PID user (page specific user id).

Making the follow request to Facebook Graph API:

GET https://graph.facebook.com/v2.6/{PAGE_SPECIFIC_USER_ID}

I discovered that I can just ask for the following fields: first_name,last_name and profile_pic.

So my question is, how could I discover if this user is a current customer of my business page? Is there another way of querying more information (like e-mail and real facebook user id)?


回答1:


Currently, there's no way to do this. The best way would be to prompt the user to enter their information in chat or give them a link to a mobile login page or some other way of linking their account to the chat.




回答2:


Facebook has updated the messenger platform 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.




回答3:


Messenger Platform 2.0 introduce "ID Matching API" ,that will solve the problem. https://developers.facebook.com/docs/messenger-platform/connecting-accounts




回答4:


you can retreive a user information like below using fbmq library 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 ...


来源:https://stackoverflow.com/questions/36832020/facebook-messenger-platform-how-to-get-user-specific-information

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!