nishtman / laravel-sms
此包帮助您使用Laravel框架调用伊朗短信服务商的API
dev-master
2019-09-05 06:27 UTC
Requires
- php: ^7.0 | ^7.1 | ^7.2
- ext-soap: *
- guzzlehttp/guzzle: *
This package is auto-updated.
Last update: 2024-09-05 17:37:27 UTC
README
这个库帮助开发者轻松地使用Laravel框架调用伊朗短信服务商的Web服务。
支持的提供商
安装
需求
php >= 7.0laravel >= 5.0
运行Composer更新命令
$ composer require nishtman/sms
- 首先,在
config/sms.php文件中设置您的短信提供商的配置,并在default部分中输入您想要的模块名称。
用法
发送短信
public function send() { /* * Instance the sms object */ $sms = new \Nishtman\Sms\Sms(); $result = $sms->send('09123456789', 'text message'); /* * or you can use facades */ $result = Nishtman\Sms\Facades\Sms::send('09123456789', 'text message'); }
选择提供商
public function send() { /* * Instance the sms object */ $sms = new \Nishtman\Sms\Sms(); $result = $sms->provider('HostIran')->send('09123456789', 'text message') /* * or you can use facades */ $result = Nishtman\Sms\Facades\Sms::provider('HostIran')->send('09123456789', 'text message'); }
方法和API
/* * Set the provider */ provider(string $provider): \Nishtman\Sms\sms
/* * Set sms message */ send(string $to, string $text): array /* * Array * ( * [status] => 'integer status code' * [message] => 'string message' * [referenceId] => 'integer reference id to get the delivery report' * ) */
/* * Get the delivery status */ delivery(int $referenceId): array /* * Array * ( * [string] => 'string status text' * ) */
/* * Get the credits value */ getCredits(int $referenceId): int /* * Array * ( * [int] => 'your credit amount' * ) */