adolphyu/laravel-facebook-messenger
Composer 安装命令:
composer require adolphyu/laravel-facebook-messenger
包简介
A Laravel Package to Integrate Facebook Messenger API
README 文档
README
This is a laravel package for Facebook Messenger Platform API.
Easy to making your facebook messenger.
Installation
Composer
composer require adolphyu/laravel-facebook-messenger
Laravel
Add Provider
In your config/app.php add AdolphYu\FBMessenger\PackageServiceProvider::class to the providers array:
'providers' => [ ... AdolphYu\FBMessenger\PackageServiceProvider::class, ... ], 'alias => [ ... 'FBMSG' => AdolphYu\FBMessenger\Facades\FBMSG::class, ... ],
Publish Configuration
php artisan vendor:publish --provider="AdolphYu\FBMessenger\PackageServiceProvider" --tag="config"
Configuration
Security
Almost every API request with access_token, if you want to improved security in your app,
you can use appsecret_proof. Please add MESSENGER_APP_SECRET to .env file and enable proof on all calls.
If you don't know how to get secret token and enabled proof, please checkout Graph Api
.env
MESSENGER_APP_SECRET="APP SECRET TOKEN"
Token
Add you token to .env file or modify fb-messenger.php config.
If you don't know how to get token, please checkout Facebook Developer
.env
...
MESSENGER_VERIFY_TOKEN="By You Writing"
MESSENGER_APP_TOKEN="Page Access Token"
...
Custom Url
If you want to custom url, replace /webhook to you want.
Finally, you can run php artisan route:list to check.
return [ 'verify_token' => env('MESSENGER_VERIFY_TOKEN'), 'app_token' => env('MESSENGER_APP_TOKEN'), 'custom_url' => '/chatbot', // like this ];
Receive Message
Processes
The Process will process the information sent by facebook messenger
THe Process must implement ProcessInterface interface.
There is a method handle in the ProcessInterface , which processes the information sent by facebook messenger
You can check out ProcessInterface
If you need to add or customize process, you must implement this interface
<?php namespace App; use AdolphYu\FBMessenger\Processes\Process; class CustomProcess extends Process { public function handle($data) { //your code dd($data); } }
If you want to know $data , you can refer to Webhook
Add code in the boot method of the AppServiceProvider or other ServiceProvider
<?php 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 } } }
Processes using the system
You can check out Processes
Source code Processes
Send Message
After completing the configuration, sending a message will become very simple
Examples are as follows
use AdolphYu\FBMessenger\Models\TextMessaging; Route::get('/', function () { FBMSG::send(new TextMessaging('<psid>','HELLO')); });
Debug
If you set debug=true in the fb-messenger.php file, you will see debug information in the log file
Thanks
https://github.com/CasperLaiTW/laravel-fb-messenger
License
This package is licensed under the MIT license.
adolphyu/laravel-facebook-messenger 适用场景与选型建议
adolphyu/laravel-facebook-messenger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 119 次下载、GitHub Stars 达 7, 最近一次更新时间为 2020 年 09 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「facebook」 「laravel」 「Messenger」 「chatbot」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 adolphyu/laravel-facebook-messenger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 adolphyu/laravel-facebook-messenger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 adolphyu/laravel-facebook-messenger 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Simple Sharing generates social media share links within CP entry pages, allowing you to quickly & easily share entries.
Enables the creation of cron-jobs tasks to be consumed by symfony/messenger
Messenger functionality for Laravel 5.2.
统计信息
- 总下载量: 119
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-09-16