Facebook messenger API sender name not available

时间:2016-10-20 12:35:04

标签: facebook facebook-graph-api facebook-messenger

I have a bot using the Facebook Messenger API/webhook. When Facebook sends a message the sender only has the id set, not the name.

So I try to get the name using the graph API using,

https://graph.facebook.com/v2.6/<sender-id>?fields=first_name,last_name&access_token=<page-token>

The sender id it gives you does not seem to be the real id, so using your app token does not work, but using the page token does not seem to work all the time either.

From my logs I see it work some time, and not others. I get the error,

(#100) No matching user found

My only guess is that if it is an older conversation, the id it gives you have expired somewhere, so you cannot get the name?

Anyone else have this issue, or find a work around?

1 个答案:

答案 0 :(得分:1)

好的,想通了,用户错误。

问题是我在测试时有另一个链接到该页面的应用程序,我没有删除webhook。因此,webhook被调用了两次,其中一个因为其他原因而有一个坏令牌。

无论如何从其他应用程序中删除webhook解决了这个问题。