我正在对API端点进行php curl调用,以基于documentation设置持久性菜单。这是代码:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/v2.6/me/thread_settings?access_token='.FB_ACCESS_TOKEN);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postbody);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
$output = curl_exec($ch);
curl_close($ch);
error_log($output);
ACCESS_TOKEN设置正确,$ postbody看起来像这样:
{"setting_type":"call_to_actions","thread_state":"existing_thread","call_to_actions":[{"type":"postback","title":"My Album","payload":"{\"type\":\"button1\",\"data\":{\"category\":\"album\"}}"},{"type":"postback","title":"Help","payload":"{\"type\":\"button1\",\"data\":{\"category\":\"help\"}}"}]}
我得到了一个成功的结果:
{"result":"Successfully added structured menu CTAs"}
菜单在Facebook上的计算机上工作:
但它根本没有出现在移动Messenger应用程序上。我在其他地方读过它被缓存并花时间刷新,但我已经等了24个多小时了。此外,在Android手机和iPhone上都进行了测试,但仍看不到菜单。
答案 0 :(得分:2)
您必须在移动设备上重新启动Facebook Messenger应用程序,因为移动应用程序会在启动时缓存菜单。