airoude / messagebird-bundle
MessageBird meets Symfony
Installs: 2 515
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 0
Forks: 0
Type:symfony-bundle
This package has no released version yet, and little information is available.
README
Installation
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require airoude/messagebird-bundle "~0.2"
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new Airoude\MessageBirdBundle\AiroudeMessageBirdBundle(), ); // ... } // ... }
Step 3: Configure the Bundle
// app/config/config.yml airoude_messagebird: api: access_key: "YOUR_ACCESS_KEY" vmn: enabled: true chat: channels: telegrambot: name: 'Test Channel Telegram' platform_id: 'e82d332c5649a5f911e569n69040697' botname: 'BayMaxBot' token: 'YOUR_TOKEN_KEY'
Include routing
// app/config/routing.yml airoude_messagebird: resource: "@AiroudeMessagebirdBundle/Resources/config/routing.xml" prefix: /messagebird
Configure MessageBird endpoints to https://acme-company.com/messagebird/(status|hlr|vmn|chat|shortcode)
Usage example
Sending a text message.
<?php namespace Acme\DemoBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; class HomeController extends Controller { public function indexAction() { // ... $messagebird = $this->get('airoude.messagebird.client'); $message = new \MessageBird\Objects\Message(); $message->originator = 'MessageBird'; $message->recipients = array(31612345678); $message->body = 'This is a test message.'; $result = $messagebird->messages->create($message); // ... } } ?>
Receiving a callback
<?php namespace Acme\DemoBundle\EventListener; use Symfony\Bundle\FrameworkBundle\Controller\Controller; class SomeListener { public function onStatus(StatusEvent $event) { // do something with event } public function onHlr(HlrEvent $event) { // do something with event } public function onChat(ChatEvent $event) { // do something with event } public function onVmn(VmnEvent $event) { // do something with event } public function onShortCode(ShortCodeEvent $event) { // do something with event } } ?>
<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> <services> // ... <service id="some.listener" class="Acme\DemoBundle\EventListener\SomeListener"> <tag name="kernel.event_listener" event="airoude.messagebird.status_callback" method="onStatus"/> <tag name="kernel.event_listener" event="airoude.messagebird.hlr_callback" method="onHlr"/> <tag name="kernel.event_listener" event="airoude.messagebird.chat_callback" method="onChat"/> <tag name="kernel.event_listener" event="airoude.messagebird.vmn_callback" method="onVmn"/> <tag name="kernel.event_listener" event="airoude.messagebird.shortcode_callback" method="onShortCode"/> </service> // ... </services> </container>
Testing
$ php composer.phar update $ phpunit
License
This bundle is under the MIT license. See the complete license.
Credits
Author - Youssef Airoude