samiaraboglu / fb-messenger-api-bundle
Symfony Facebook Messenger Api Bundle
Installs: 186
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=7.1.3
- samiaraboglu/fb-messenger-bot-php: ^2.0
- symfony/framework-bundle: 4.*
This package is auto-updated.
Last update: 2024-12-29 06:27:15 UTC
README
Use the Facebook Messenger PHP API.
Download the Bundle
$ composer require samiaraboglu/fb-messenger-api-bundle
Enable the Bundle
Registered bundles in the config/bundles.php
file of your project:
return [ // ... Samiax\FbMessengerApiBundle\FbMessengerApiBundle::class => ['all' => true], // ... ];
Config
Add this to config/packages/fb_messenger_api.yaml:
fb_messenger_api: access_token: %fb_messenger_api_access_token% verify_token: %fb_messenger_api_verify_token%
Example
Send text message:
namespace App\Controller\Messenger; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\HttpFoundation\Response; use Samiax\FbMessengerApiBundle\Service\MessengerApi; /** * Messenger Controller * * @Route("/messenger", name="app_messenger_") */ class MessengerController extends AbstractController { /** * @Route("/send", name="send") * * @return Response */ public function sendAction(MessengerApi $messengerApi) { $messenger = $messengerApi->messenger; $message = $messenger->message; $message->text('<MESSAGE_TEXT>'); $messenger->send(<PSID>, $message); return new Response(); } }