Allows to implement subscription on Viber's account and broadcast notifications to different groups (roles) of subscribed users.
composer require sokil/php-viber-notifier
Viber informs server about events by webhook. It must be passed to Viber using API.
For Example:
#!/bin/sh
curl -XPOST -H 'X-Viber-Auth-Token: your-bot-api-token' "https://chatapi.viber.com/pa/set_webhook" -d '{"url": "https://server.com/chatbot/webhook/viber", "event_types": ["subscribed","unsubscribed","conversation_started"], "send_name": true, "send_photo" : true}'
To start sending notifications via Viber we need to create bot first.
When user joins Viber's chatbot, Viber sends postback request to our site with subscribed user details. Then we may send notifications to all subscribed users.
Users may have different roles, so we may broadcast different messages to different roles of users.
First we need to implement storage where subscribed Viber users and their roles will be stored.
Storage must implement SubscribersRepositoryInterface
.
If you already have convigured Viber bot in your project, just create adapter by implementing interface ViberClientInterface
.
If you have no chatbot in you project, use basic implementation ViberClient
.