How can use botman for multiple pages (multiple page access token) - Facebook
I'm using botman with one app id and one page access token.
How can I use my botman for multiple pages and work on multiple pages at the same time?
Where can I set an array of page access token?
i got the same problem, i found this link, but when trying to apply the solution I was not successful.
https://github.com/botman/botman/issues/865
Tell me if u had success
@xrami @christian482 If you are using BotmanStudio, the following solution can help you.
go to FacebookDriver.php
public function buildPayload(Request $request){
$this->payload = new ParameterBag((array) json_decode($request->getContent(), true));
$this->event = Collection::make((array) $this->payload->get('entry')[0]);
$this->signature = $request->headers->get('X_HUB_SIGNATURE', '');
$this->content = $request->getContent();
//HERE MY CUSTOM BLOCK
$config = config('botman.facebook', []);
$recipient_id = $this->event->get('messaging')[0]['recipient']['id'];
$token = null;
if(!($recipient_id == null OR $recipient_id == "")){
$key = 'page_token_'.$recipient_id;
$token = Cache::remember($key, 60, function () use ($recipient_id) {
$page_access_token = ;//search_your_page_token_by_recipient_id_here
return $page_access_token;
});
}
if($token == null){
$this->config = Collection::make($this->config->get('facebook', []));
}else{
$config['token'] = $token;
$this->config = Collection::make($config);
}
}
Otherwise, If you don't use BotmanStudio, you can use like that
$config = [
'facebook' => [
'token' => 'page_token',
'app_secret' => 'app_secret',
'verification' => 'webhook_token',
],
];
// dynamic page_token logic here
// here your logic
$botman = BotManFactory::create($config);
All solutions are need to set dynamic page token. You need to write a dynamic page token logic only.
@KyawNaingTun could you share your project? Thank you so much with dynamic page token logic any examples please
I would also appreciate it, I have also had problems integrating it and if I need it a lot
where i found: search_your_page_token_by_recipient_id_here that you use here "$page_access_token = ;//search_your_page_token_by_recipient_id_here"