使用 sender.id 获取 Facebook 用户 ID
Get facebook userID with sender.id
这是当我的页面收到一条消息时 webhook 发送给我的更改事件:
{
"object":"page",
"entry":
[{"id":"718511138248476","time":1470310180982,
"messaging":
[{"sender":{"id":"845775748857562"},
"recipient":{"id":"718511138248476"},
"timestamp":1470310180901,
"message":
{"mid":"mid.1470310180891:612cfb6aead5fca278",
"seq":468,
"text":"hello"}
}]
}]}
但是我怎么知道实际上是哪个用户发送了这条消息?有什么方法可以使用 sender.id 获取用户 facebook ID 吗?
关于第二个问题:sender.id 是始终不变还是会改变?我的意思是,当我打算稍后向用户发送消息时,将 sender.id 保存在数据库中是否明智?
您可以在此处阅读文档 https://developers.facebook.com/docs/messenger-platform/user-profile。但是响应字段没有 "id".
这是当我的页面收到一条消息时 webhook 发送给我的更改事件:
{
"object":"page",
"entry":
[{"id":"718511138248476","time":1470310180982,
"messaging":
[{"sender":{"id":"845775748857562"},
"recipient":{"id":"718511138248476"},
"timestamp":1470310180901,
"message":
{"mid":"mid.1470310180891:612cfb6aead5fca278",
"seq":468,
"text":"hello"}
}]
}]}
但是我怎么知道实际上是哪个用户发送了这条消息?有什么方法可以使用 sender.id 获取用户 facebook ID 吗?
关于第二个问题:sender.id 是始终不变还是会改变?我的意思是,当我打算稍后向用户发送消息时,将 sender.id 保存在数据库中是否明智?
您可以在此处阅读文档 https://developers.facebook.com/docs/messenger-platform/user-profile。但是响应字段没有 "id".