serious/sviber-bot-php
Composer 安装命令:
composer require serious/sviber-bot-php
包简介
Php bot interface to work with Viber API
README 文档
README
Library to develop a bot for the Viber platform. Create you first Viber bot step by step, see demo at viber://pa?chatURI=viber-bot-php&context=github.com
Installation
composer require bogdaan/viber-bot-php
Example
<?php require_once("../vendor/autoload.php"); use Viber\Bot; use Viber\Api\Sender; $apiKey = '<PLACE-YOU-API-KEY-HERE>'; // reply name $botSender = new Sender([ 'name' => 'Whois bot', 'avatar' => 'https://developers.viber.com/img/favicon.ico', ]); try { $bot = new Bot(['token' => $apiKey]); $bot ->onConversation(function ($event) use ($bot, $botSender) { // this event fires if user open chat, you can return "welcome message" // to user, but you can't send more messages! return (new \Viber\Api\Message\Text()) ->setSender($botSender) ->setText("Can i help you?"); }) ->onText('|whois .*|si', function ($event) use ($bot, $botSender) { // match by template, for example "whois Bogdaan" $bot->getClient()->sendMessage( (new \Viber\Api\Message\Text()) ->setSender($botSender) ->setReceiver($event->getSender()->getId()) ->setText("I do not know )") ); }) ->run(); } catch (Exception $e) { // todo - log exceptions }
See more in examples directory.
Library structure
.
├── Api
│ ├── Entity.php
│ ├── Event # all remote events ("callbacks")
│ │ ├── Conversation.php # fires when user open 1v1 chat
│ │ ├── Delivered.php # fires when message delivered (for each device)
│ │ ├── Factory.php # Event factory
│ │ ├── Failed.php # fires when delivery failed (for each device)
│ │ ├── Message.php # fires when user send message
│ │ ├── Seen.php # fires when user read message (for each device)
│ │ ├── Subscribed.php # fires when user subscribe to PA
│ │ ├── Type.php # available types
│ │ └── Unsubscribed.php # fires when user unsubscribed
│ ├── Event.php # base class for all events
│ ├── Exception #
│ │ └── ApiException.php # remote or logic error
│ ├── Keyboard #
│ │ └── Button.php # all types of buttons here
│ ├── Keyboard.php # button container
│ ├── Message #
│ │ ├── CarouselContent.php #
│ │ ├── Contact.php #
│ │ ├── Factory.php #
│ │ ├── File.php #
│ │ ├── Location.php #
│ │ ├── Picture.php #
│ │ ├── Sticker.php #
│ │ ├── Text.php #
│ │ ├── Type.php # available message types
│ │ ├── Url.php #
│ │ └── Video.php #
│ ├── Message.php # base class for all messages
│ ├── Response.php # wrap api response
│ ├── Sender.php # represent bot-sender
│ ├── Signature.php # signature helper (verify or create sign)
│ ├── User #
│ │ └── State.php # user state (online/offline etc)
│ └── User.php # viber user
├── Bot #
│ └── Manager.php # manage bot closures
├── Bot.php # bot class
└── Client.php # api client
Read more
Features
- all api entities
- validate request and response signs
- provide webhook interface
- provide event interface
- wrap all api response to entities
- validate api entities before submit?
- implement log levels with monolog?
- post on public page
Contributing
Pull requests are welcome.
serious/sviber-bot-php 适用场景与选型建议
serious/sviber-bot-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 142 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 09 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「bot」 「im」 「viber」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 serious/sviber-bot-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 serious/sviber-bot-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 serious/sviber-bot-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dialogflow php sdk
Laravel 5.6 Monolog custom telegram channel
CM.com TextClient in a Laravel Service Provider.
The library implement SMS Aero api v2
VK driver for botman
Allows to implement subscription on Viber's account and broadcast notifications to different groups of subscribed userss,
统计信息
- 总下载量: 142
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-09-09