Facebook Messenger平台/漫游器欢迎配置出现奇怪的错误
为Messenger机器人配置欢迎消息时出现奇怪的错误.我一直在使用相同的代码(如下所示),直到昨晚它一直运行良好.我同时使用cURL和邮递员进行了尝试.它们都不起作用.
I'm getting a weird error while configuring welcome message for my Messenger bot. I've been using the same code (as shown below) and it has just been working fine until last night. I tried it with both cURL and Postman. Neither of them works.
curl -X POST -H "Content-Type: application/json" -d '{
"setting_type":"call_to_actions",
"thread_state":"new_thread",
"call_to_actions":[
{
"message":{
"text":"Welcome to My Company!"
}
}
]
}' "https://graph.facebook.com/v2.6/<PAGE_ID>/thread_settings?access_token=<PAGE_ACCESS_TOKEN>"
执行上面的代码时出现错误消息:
{"error":{"message":"(#100) Invalid keys \"message\" were found in param \"call_to_actions[0]\".","type":"OAuthException","code":100,"fbtrace_id":"Hn42Wa+hapI"}}%
我可以确认PAGE_ID和PAGE_ACCESS_TOKEN都是正确的,因为尝试使用以下代码删除欢迎消息是可行的.
I can confirm both PAGE_ID and PAGE_ACCESS_TOKEN are correct as trying to delete the welcome message with the following code works fine.
curl -X POST -H "Content-Type: application/json" -d '{
"setting_type":"call_to_actions",
"thread_state":"new_thread",
"call_to_actions":[
{
"message":{
"text":"Welcome to My Company!"
}
}
]
}' "https://graph.facebook.com/v2.6/<PAGE_ID>/thread_settings?access_token=<PAGE_ACCESS_TOKEN>"
此外,我使用的代码与 Facebook上显示的代码完全相同官方API文档.我不明白为什么说消息"不是有效的密钥.有人遇到同样的问题吗? Facebook是否更改了他们的API?
Also, the code I'm using is exactly the same as shown on the Facebook official API doc. I don't understand why it's saying "message" is not a valid key. Is anyone experiencing the same problem? Did Facebook change their api?
任何帮助将不胜感激!
Any help will be much appreciated!
docs 现在已更新,您需要立即在payload
参数中定义有效负载(UTF-8编码的字符串),例如:
The docs are now updated, you need to define your payload in payload
parameter now (a UTF-8 encoded string), eg:
"call_to_actions":[
{
"payload":"USER_DEFINED_PAYLOAD"
}
]