Meta clearly says this on top of the page with dashboard so i made sure am using there test.
Applications will only be able to receive test webhooks sent from the app dashboard while they are in development. No production data, including that of app admins, developers, and testers, will be delivered unless the app is live.
I have successfully completed web-hook verification which worked fine and i even logged it, i did configure it correctly.
The issue comes when i send press the test for message i do not receive any thing.
Here is my route and controller function
Route::match(['get', 'post'], '/webhook-receiving-url', [WebController::class, 'verification'])
->name('verification');
Below is the function.
public function verification(Request $request)
{
if($request->isMethod('get')){
if($request->input('hub_verify_token')=="xxxxxxxx"){
log::info('validation success');
$challenge = $request->input('hub_challenge');
return response($challenge,200);
}
}elseif($request->isMethod('post')){
// Log the incoming content
Log::info('Incoming content: ' . $request->getContent());
return response('Event received', 200);
}
// If the request method is neither GET nor POST
return response('Invalid request method', 405);
}
Apparently for webhooks which will be receiving a post request you have to do some altering on the verifyCsrfToken.php in the middleware.
If you don't the request does not come through since for post request in laravel they have to go through the Csrf token verification so you have to exempt your route by going to verifyCsrfToken.php which is in your middleware folder and have to list your route there,
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
'/your-route-here',
];
}
Before you do this you will not even be able to log to see if the request reaches your server.
For reference this guy explained better https://stackoverflow.com/a/77512153/16273234