botman / driver-facebook

BotMan Facebook Messenger Driver
MIT License
71 stars 72 forks source link

Call to undefined method Symfony\Component\HttpFoundation\Response::create() when adding webhook in facebook. #122

Open NowakAdmin opened 2 years ago

NowakAdmin commented 2 years ago

Description:

Hi, im geting this error in laravel 9, how to handle it easiest way?

method create not exist, so should i make new class that extends Request with method create ?

I already tried to change all references from use Symfony\Component\HttpFoundation\Response; to Illuminate\Http\Response (and Request) but this also not work.

curl -X GET "https://mydomain.com/botman?hub.verify_token=MySecretTokenFromDotENV&hub.challenge=CHALLENGE_ACCEPTED&hub.mode=subscribe"

Reponse:

Error: Call to undefined method Symfony\Component\HttpFoundation\Response::create() in file /var/www/nams/botman/driver-facebook/src/FacebookDriver.php on line 120

#0 /var/www/nams/botman/botman/src/Drivers/DriverManager.php(157): BotMan\Drivers\Facebook\FacebookDriver->verifyRequest()
#1 /var/www/nams/botman/botman/src/BotMan.php(542): BotMan\BotMan\Drivers\DriverManager::verifyServices()
#2 /var/www/nams/botman/botman/src/BotMan.php(421): BotMan\BotMan\BotMan->verifyServices()
#3 /var/www/nams/app/Http/Controllers/BotManController.php(40): BotMan\BotMan\BotMan->listen()
#4 /var/www/nams/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\Http\Controllers\BotManController->handle()...

Steps To Reproduce:

Install botman on laravel 9 from local repository (path) change in composer/json dependencies to fit laravel 9 Try to connect to facebook like:

        $config = [
            'user_cache_time' => 720,

            'config' => [
                'conversation_cache_time' => 720 ,
            ],
            // Your driver-specific configuration
            'facebook' => [
                'token' => env('FACEBOOK_TOKEN'),
                'app_secret' => env('FACEBOOK_APP_SECRET'),
                'verification' => env('FACEBOOK_VERIFICATION'),
            ]
        ];
        $botman = app('botman');
        DriverManager::loadDriver(\BotMan\Drivers\Facebook\FacebookDriver::class);
        BotManFactory::create($config, new LaravelCache());
        $botman->listen();

try to get response for facebook by: curl -X GET "https://mydomain.com/botman?hub.verify_token=MySecretTokenFromDotENV&hub.challenge=CHALLENGE_ACCEPTED&hub.mode=subscribe"

donmbelembe commented 1 year ago

hello, did you manage to find solution ?

gocebo commented 1 year ago

There are 2 options:

  1. Downgrade to http-foundation 5.x if possible composer require symfony/http-foundation "^5.4"
  2. Fork the package and make the changes suggested by @donmbelembe till the package is updated