polygontech / sms-service-client
通过 Polygon Technology 的 sms-service 发送短信
1.0.0
2022-12-11 11:47 UTC
Requires
- php: >=8.1.0
- guzzlehttp/guzzle: ^7.0
- polygontech/common-helpers: ^1.0
README
通过 Polygon Technology 的 sms-service 发送短信
polygontech/sms-service-client 主要用于 polygontech 的 laravel 项目中,结合 sms-service(例如) 使用,该 sms-service 负责作为微服务发送短信。因此,在集成此客户端之前,请确保安装并运行 sms-service。
安装
推荐使用 Composer 进行安装。运行以下命令安装包并将其添加到项目 composer.json
文件的依赖项中
composer require polygontech/sms-service-client
然后,发布所需的配置
php artisan vendor:publish --provider='Polygontech\SmsService\ServiceProvider' # or, php artisan vendor:publish # and select 'Polygontech\SmsService\ServiceProvider' when prompted
使用方法
首先,创建一个实现名为 Feature
的 interface
的 enum
。 该 enum
应包含由安装的短信服务支持的 features 的情况。 例如,对于支持 test, otp 功能的 sms-service,该 enum
应该看起来像
use Polygontech\SmsService\Inputs\Feature; enum SmsFeatures implements Feature { case TEST; case OTP; public function getFeatureType(): string { switch ($this) { case self::TEST: return "test"; case self::OTP: return "otp"; } } } // or, enum SmsFeatures : string implements Feature { case TEST = "test"; case OTP = "otp"; public function getFeatureType(): string { return $this->value; } }
然后,发送单个短信
use Polygontech\CommonHelpers\Mobile\BDMobile; use Polygontech\SmsService\Facades\Sms; use Polygontech\SmsService\Responses\SingleSmsResponse; /** @var SingleSmsResponse $output */ $output = Sms::shoot(SmsFeatures::TEST, new BDMobile("+8801678242960"), "test sms"));
发送批量短信
use Polygontech\CommonHelpers\Mobile\BDMobile; use Polygontech\SmsService\Facades\Sms; use Polygontech\SmsService\Responses\BulkSmsResponse; /** @var BulkSmsResponse $output */ $output = Sms::shoot(SmsFeatures::TEST, [ new BDMobile("+8801678242960"), new BDMobile("+8801678242961"), ], "test bulk sms"));
贡献
欢迎贡献!要贡献,请熟悉 CONTRIBUTING.md。
版权和许可
polygontech/nagad-disbursement 库版权所有 © Shafiqul Islam,Polygon Technology,并按照 MIT 许可证(MIT)许可使用。有关更多信息,请参阅 LICENSE。