かまえ1か / あみ
为 Laravel 提供 asterisk あみ
4.1.1
2021-03-17 04:43 UTC
Requires
- php: >=5.6.0
- ext-mbstring: *
- clue/ami-react: ~0.3.1
- illuminate/console: *
- illuminate/contracts: *
- illuminate/events: *
- illuminate/support: *
- react/dns: ~0.4.3
- react/event-loop: ~0.4.2
- react/socket-client: ~0.4.6
- react/stream: ~0.4.6
Requires (Dev)
- friendsofphp/php-cs-fixer: ~2.0.0
- illuminate/config: ~5.1
- illuminate/container: ~5.1
- phpunit/phpunit: ~4.5|~5.0
README
Enniel\Ami laravel 8+
通过 asterisk 管理接口 (AMI) 实现简单控制。
安装和配置
要将它作为 composer 包安装并用于 Laravel 8+,只需运行
composer require "enniel/ami"
安装完成后,您可以在 config/app.php
文件的 providers
数组中注册服务提供者。
'providers' => [ \Enniel\Ami\Providers\AmiServiceProvider::class, ]
然后使用 php artisan vendor:publish
发布资产。这将添加 config/ami.php
文件。
使用方法
连接选项
您可以为每个命令指定连接参数。
监听 ami 事件
php artisan ami:listen
Artisan::call('ami:listen');
如果您想在控制台查看事件日志,请使用 monitor 选项。
php artisan ami:listen --monitor
发送 ami 动作
php artisan ami:action <action> --arguments=<key>:<value> --arguments=<key>:<value> ...
Artisan::call('ami:action', [ 'action' => <action>, '--arguments' => [ <key> => <value> ... ] ]);
使用 chan dongle 发送短信消息。
php artisan ami:dongle:sms <phone> <message> <device?>
Artisan::call('ami:dongle:sms', [ 'phone' => <phone>, 'message' => <message>, 'device' => <device?>, ]);
要发送长消息,请使用 pdu 模式。
php artisan ami:dongle:sms <phone> <message> <device?> --pdu
Artisan::call('ami:dongle:sms', [ 'phone' => <phone>, 'message' => <message>, 'device' => <device?>, '--pdu' => true, ]);
不需要指定设备参数。
使用 chan dongle 发送 ussd 命令。
php artisan ami:dongle:ussd <device> <ussd>
Artisan::call('ami:dongle:ussd', [ 'device' => <device>, 'ussd' => <ussd>, ]);
发送 ami 命令
此命令启动 ami 的 cli 接口。命令属性是可选的。
php artisan ami:cli [command]
发送命令后关闭 cli 接口。
php artisan ami:cli [command] --autoclose
Artisan::call('ami:cli', [ 'command' => [command], '--autoclose' => true, ]);
不使用 Laravel
php ./vendor/bin/ami ami:listen --host=127.0.0.1 --port=5038 --username=username --secret=secret --monitor