简体   繁体   中英

Laravel Botman: Can't get Facebook Messenger User

I am using Botman Studio . I am facing an unexpected error while using Botman $bot->getUser() API. I have added welcome screen and get started payload. It works fine.When user clicks Get_started, i want to store user's information. But Laravel Log says:

local.ERROR: Error sending payload: (#100) Insufficient permission to access user profile. {"exception":"[object] (BotMan\\Drivers\\Facebook\\Exceptions\\FacebookException(code: 0): Error sending payload: (#100) Insufficient permission to access user profile. at /..../vendor/botman/driver-facebook/src/FacebookDriver.php:501)

Please help. I am new to Botman. TIA.

File: App\\Http\\Controllers\\BotmanController.php

 public function handle()
{
    $botman = app('botman');
    $botman->hears('GET_STARTED', function (BotMan $bot) {
        $bot_user = $bot->getUser();
        Log::info(\GuzzleHttp\json_encode($bot_user));
        $bot->reply("Hello! $bot_user->getFirstName()");
    });

    $botman->listen();
}

I have also tried Botman $bot->getDriver() . But it returns null, though Botman $bot->getDriver()->getName() returns Facebook .
Laravel Version: 5.6
Botman Version: 2.0

Please test the same functionality using your developer account. Facebook needs to approve permissions to access user information if your bot is in production or is public (Can be accessed by everyone). If it works with your facebook account (I am assuming you are the admin of both the facebook page and the developer app where the bot is connected.), Then you need to go to the messenger tab on the facebook developers page and scroll down to App Review for Messenger and make all the available permission requests submissions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM