You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm attempting to utilize the Facebook driver instance to send a message to a Facebook user, but it's not functioning as expected. I'm receiving the error message 'Failed to retrieve Facebook driver or driver is not an instance of FacebookDriver.' My intention is to send the message when I make a request to 'https://myserver/api/send-message' using Postman. When I do get_class($facebookDriver) it throws: BotMan\BotMan\Drivers\NullDriver"
namespace App\Http\Controllers;
use BotMan\BotMan\BotMan;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use BotMan\Drivers\Facebook\FacebookDriver;
public function sendMessage()
{
try {
$botman = app('botman');
$facebookDriver = $botman->getDriver(\BotMan\Drivers\Facebook\FacebookDriver::class);
if ($facebookDriver && $facebookDriver instanceof FacebookDriver) {
$recipient = '1**';
$message = 'hello world';
$payload = [
'messaging_type' => 'RESPONSE',
'recipient' => [
'id' => $recipient
],
'message' => [
'text' => $message
]
];
$facebookDriver->sendPayload($payload);
Log::info('Payload sent successfully to recipient: ' . $recipient);
return response()->json(['status' => 'success']);
} else {
Log::error('Failed to retrieve Facebook driver or driver is not an instance of FacebookDriver.');
return response()->json(['status' => 'error', 'message' => 'Failed to retrieve Facebook driver.'], 500);
}
} catch (\Exception $e) {
Log::error('Error sending payload: ' . $e->getMessage());
return response()->json(['status' => 'error', 'message' => $e->getMessage()], 500);
}
}
Description:
I'm attempting to utilize the Facebook driver instance to send a message to a Facebook user, but it's not functioning as expected. I'm receiving the error message 'Failed to retrieve Facebook driver or driver is not an instance of FacebookDriver.' My intention is to send the message when I make a request to 'https://myserver/api/send-message' using Postman. When I do get_class($facebookDriver) it throws: BotMan\BotMan\Drivers\NullDriver"
api.php:
Route::post('/send-message', [BotManController::class, 'sendMessage']);
Steps To Reproduce:
The text was updated successfully, but these errors were encountered: