Facebook Messenger API - Persistent Menu not worki

2020-07-10 08:57发布

问题:

I am making a php curl call to the API endpoint to set up a persistent menu based on the documentation. Here is the code:

$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);

The ACCESS_TOKEN is set correctly and the $postbody looks like this:

{"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\"}}"}]}

I get back a successful result:

{"result":"Successfully added structured menu CTAs"}

And the menu works on facebook on the computer on web:

But it simply does not appear on the mobile Messenger app. I've read elsewhere about it being cached and taking time to refresh, but I've waited over 24 hours now. Also, tested on both an Android phone and an iPhone and still don't see the menu.

回答1:

You have to restart the Facebook Messenger application on your mobile, because the moblie application caches the menu on start.