PHP code example of adolphyu / laravel-facebook-messenger
1. Go to this page and download the library: Download adolphyu/laravel-facebook-messenger library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
adolphyu / laravel-facebook-messenger example snippets
return [
'verify_token' => env('MESSENGER_VERIFY_TOKEN'),
'app_token' => env('MESSENGER_APP_TOKEN'),
'custom_url' => '/chatbot', // like this
];
namespace App;
use AdolphYu\FBMessenger\Processes\Process;
class CustomProcess extends Process
{
public function handle($data)
{
//your code
dd($data);
}
}
namespace App\Providers;
use App\CustomProcess;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
if($this->app->get('fbmsg')){
$this->app->get('fbmsg')->addProcess(new CustomProcess());//like this
}
}
}
use AdolphYu\FBMessenger\Models\TextMessaging;
Route::get('/', function () {
FBMSG::send(new TextMessaging('<psid>','HELLO'));
});