为 Facebook 聊天扩展设置主页 URL
Setting the home URL for Facebook chat extension
根据 Facebook 文档 https://developers.facebook.com/docs/messenger-platform/guides/chat-extensions#drawer "To allow your bot to appear in the drawer for people who have added it, you must set its home URL."
我正在按照文档 https://developers.facebook.com/docs/messenger-platform/messenger-profile/domain-whitelisting 设置域白名单,然后设置主页 URL
# add domain to whitelist
curl -X POST -H "Content-Type: application/json" -d '{
"whitelisted_domains":[
$URL
]
}' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=$ACCESS_TOKEN"
# set domain as home URL
curl -X POST -H "Content-Type: application/json" -d '{
"home_url" : {
"url": $URL,
"webview_height_ratio": "tall",
"in_test":true
}
}' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=$ACCESS_TOKEN"
两者 return 一条成功消息
{
"result":"success"
}
但是当我通过 运行
检查为白名单域和家庭 URL 设置的内容时
# get home URL
curl -X GET "https://graph.facebook.com/v2.6/me/messenger_profile?fields=home_url&access_token=$ACCESS_TOKEN"
# get existing whitelist domains
curl -X GET "https://graph.facebook.com/v2.6/me/messenger_profile?fields=whitelisted_domains&access_token=$ACCESS_TOKEN"
我收到奇怪的回复
{"data":[]}%
我是不是漏掉了一个步骤,或者获取白名单域和主页 URL 的响应是否损坏?
原来我的终端没有正确显示响应。我通过邮递员提出了同样的请求,它正确地显示了列入白名单的域。我花了一段时间才弄明白这一点,希望这能帮助遇到同样问题的任何人。
根据 Facebook 文档 https://developers.facebook.com/docs/messenger-platform/guides/chat-extensions#drawer "To allow your bot to appear in the drawer for people who have added it, you must set its home URL."
我正在按照文档 https://developers.facebook.com/docs/messenger-platform/messenger-profile/domain-whitelisting 设置域白名单,然后设置主页 URL
# add domain to whitelist
curl -X POST -H "Content-Type: application/json" -d '{
"whitelisted_domains":[
$URL
]
}' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=$ACCESS_TOKEN"
# set domain as home URL
curl -X POST -H "Content-Type: application/json" -d '{
"home_url" : {
"url": $URL,
"webview_height_ratio": "tall",
"in_test":true
}
}' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=$ACCESS_TOKEN"
两者 return 一条成功消息
{
"result":"success"
}
但是当我通过 运行
检查为白名单域和家庭 URL 设置的内容时# get home URL
curl -X GET "https://graph.facebook.com/v2.6/me/messenger_profile?fields=home_url&access_token=$ACCESS_TOKEN"
# get existing whitelist domains
curl -X GET "https://graph.facebook.com/v2.6/me/messenger_profile?fields=whitelisted_domains&access_token=$ACCESS_TOKEN"
我收到奇怪的回复
{"data":[]}%
我是不是漏掉了一个步骤,或者获取白名单域和主页 URL 的响应是否损坏?
原来我的终端没有正确显示响应。我通过邮递员提出了同样的请求,它正确地显示了列入白名单的域。我花了一段时间才弄明白这一点,希望这能帮助遇到同样问题的任何人。